/*
 * Copyright 2016 The BigDL Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.intel.analytics.bigdl.dllib.models.maskrcnn

import com.intel.analytics.bigdl.dllib.feature.dataset.segmentation.MaskUtils
import com.intel.analytics.bigdl.dllib.tensor.Tensor
import com.intel.analytics.bigdl.dllib.utils.T
import org.scalatest.{FlatSpec, Matchers}

class UtilsSpec extends FlatSpec with Matchers {
  "expandBoxes" should "be ok" in {
    val bbox = Tensor[Float](T(415.3202, 176.3966, 441.3445, 251.7300))
    val bboxExpand = Tensor[Float](4)
    Utils.expandBoxes(bbox, bboxExpand, 1.0714285714285714f)
    val expectedBBox = Tensor[Float](T(414.3907, 173.7061, 442.2739, 254.4204))
    bboxExpand should be(expectedBBox)
  }

  "expandMask" should "be ok" in {
    val mask = Tensor[Float](T(T(
      T(4.6341e-04, 3.0892e-04, 5.5805e-05, 5.3648e-05, 3.8348e-05,
        4.0923e-05, 4.0874e-05, 4.9342e-05, 1.4934e-04, 2.3377e-04,
        9.2455e-04, 1.9640e-03, 6.7012e-03, 1.1700e-02, 2.2868e-02,
        3.4102e-02, 5.0373e-02, 8.3922e-02, 1.3713e-01, 2.3499e-01,
        3.7590e-01, 4.8422e-01, 5.4733e-01, 4.8918e-01, 3.3834e-01,
        2.3584e-01, 1.9745e-01, 1.6000e-01),
      T(4.2732e-04, 2.9206e-04, 6.0863e-05, 6.0809e-05, 4.2969e-05,
        4.7592e-05, 4.0687e-05, 5.4618e-05, 1.4295e-04, 2.6305e-04,
        8.7722e-04, 2.1579e-03, 6.4814e-03, 1.2199e-02, 2.1211e-02,
        3.3435e-02, 5.0712e-02, 9.8141e-02, 1.7841e-01, 3.3267e-01,
        4.7087e-01, 5.6134e-01, 5.4585e-01, 4.3256e-01, 2.2894e-01,
        1.4579e-01, 1.1617e-01, 9.4591e-02),
      T(7.4229e-05, 4.9629e-05, 1.1812e-05, 1.1427e-05, 1.3852e-05,
        1.4571e-05, 1.6429e-05, 2.0885e-05, 7.9878e-05, 1.4078e-04,
        6.3389e-04, 1.6315e-03, 4.8276e-03, 9.6609e-03, 1.8357e-02,
        2.9629e-02, 6.4242e-02, 1.3947e-01, 2.9693e-01, 5.0719e-01,
        6.8341e-01, 7.3825e-01, 7.0431e-01, 5.7563e-01, 3.4927e-01,
        2.0407e-01, 1.4150e-01, 1.1583e-01),
      T(8.0966e-05, 5.7955e-05, 1.3771e-05, 1.4560e-05, 1.7485e-05,
        2.0353e-05, 1.9813e-05, 3.0120e-05, 8.6005e-05, 1.9037e-04,
        6.0123e-04, 1.7777e-03, 4.5884e-03, 1.0188e-02, 1.9338e-02,
        3.4767e-02, 6.8911e-02, 1.6141e-01, 3.1799e-01, 5.5213e-01,
        6.9518e-01, 7.3970e-01, 6.8841e-01, 5.5608e-01, 3.4583e-01,
        2.1902e-01, 1.3583e-01, 1.0586e-01),
      T(3.6981e-05, 2.3346e-05, 7.2523e-06, 6.9358e-06, 1.3612e-05,
        1.5485e-05, 2.5761e-05, 3.4787e-05, 1.2198e-04, 2.2105e-04,
        6.6305e-04, 1.7468e-03, 4.2893e-03, 9.8238e-03, 2.0705e-02,
        3.8232e-02, 8.9242e-02, 2.1058e-01, 4.1479e-01, 6.3925e-01,
        7.2720e-01, 7.2505e-01, 6.1903e-01, 5.4229e-01, 3.9588e-01,
        2.4779e-01, 1.7973e-01, 1.3406e-01),
      T(4.8939e-05, 3.4500e-05, 1.0843e-05, 1.2283e-05, 2.0171e-05,
        2.7103e-05, 3.6343e-05, 6.3062e-05, 1.7241e-04, 4.1421e-04,
        8.6098e-04, 2.7469e-03, 5.3915e-03, 1.4367e-02, 2.7193e-02,
        5.7192e-02, 1.1829e-01, 2.8904e-01, 4.8999e-01, 6.8236e-01,
        6.9587e-01, 6.6666e-01, 5.4644e-01, 5.2509e-01, 4.7553e-01,
        3.8484e-01, 3.1775e-01, 2.3912e-01),
      T(6.2084e-05, 3.9022e-05, 1.4060e-05, 1.4152e-05, 2.7991e-05,
        3.2111e-05, 6.1916e-05, 8.8266e-05, 3.1988e-04, 6.1125e-04,
        1.5244e-03, 3.8437e-03, 9.7983e-03, 2.1962e-02, 5.3569e-02,
        1.0839e-01, 2.3466e-01, 4.2930e-01, 6.5016e-01, 7.1807e-01,
        7.1723e-01, 6.6036e-01, 6.6802e-01, 6.3845e-01, 6.4161e-01,
        6.2048e-01, 5.2979e-01, 4.4045e-01),
      T(9.1347e-05, 6.4619e-05, 2.5321e-05, 3.1816e-05, 5.1436e-05,
        7.6462e-05, 1.1214e-04, 2.2407e-04, 6.1354e-04, 1.5753e-03,
        2.8594e-03, 8.4160e-03, 1.7025e-02, 4.0972e-02, 9.4575e-02,
        1.9026e-01, 3.7013e-01, 5.5772e-01, 6.8750e-01, 7.2380e-01,
        6.9485e-01, 6.5762e-01, 6.7078e-01, 6.5950e-01, 6.4230e-01,
        6.2810e-01, 5.1840e-01, 4.1623e-01),
      T(8.7828e-05, 6.6269e-05, 3.6323e-05, 4.4775e-05, 1.1606e-04,
        1.4916e-04, 3.7401e-04, 6.2966e-04, 2.2745e-03, 4.3958e-03,
        8.7915e-03, 1.6948e-02, 3.0861e-02, 6.1891e-02, 1.3839e-01,
        2.8432e-01, 4.8105e-01, 6.2043e-01, 7.0035e-01, 7.0787e-01,
        7.0818e-01, 6.6805e-01, 6.9580e-01, 6.7569e-01, 6.0427e-01,
        5.3689e-01, 4.2307e-01, 2.7888e-01),
      T(1.3902e-04, 1.1468e-04, 7.6237e-05, 1.1698e-04, 2.3893e-04,
        4.1147e-04, 8.1630e-04, 1.9367e-03, 5.3219e-03, 1.3054e-02,
        1.7966e-02, 3.7152e-02, 5.5747e-02, 1.1024e-01, 2.4388e-01,
        4.2369e-01, 5.9124e-01, 6.9195e-01, 7.2445e-01, 7.2798e-01,
        7.3068e-01, 7.0324e-01, 7.3541e-01, 7.3432e-01, 6.6021e-01,
        5.4254e-01, 2.8755e-01, 1.6474e-01),
      T(2.8135e-04, 2.1398e-04, 2.1649e-04, 2.7242e-04, 7.0205e-04,
        9.5946e-04, 2.1251e-03, 3.9960e-03, 1.1550e-02, 1.8662e-02,
        2.4886e-02, 3.7426e-02, 5.9397e-02, 1.1954e-01, 2.3302e-01,
        3.8706e-01, 4.9049e-01, 5.7261e-01, 5.8114e-01, 5.4481e-01,
        6.3964e-01, 6.6289e-01, 7.0789e-01, 6.9167e-01, 5.9608e-01,
        3.2595e-01, 1.3987e-01, 6.1413e-02),
      T(5.2232e-04, 4.4520e-04, 4.3554e-04, 7.0351e-04, 1.4864e-03,
        2.7261e-03, 5.5355e-03, 1.2103e-02, 2.5020e-02, 4.1414e-02,
        4.1824e-02, 6.2823e-02, 9.2860e-02, 1.6066e-01, 2.9213e-01,
        4.1854e-01, 4.8238e-01, 5.5534e-01, 5.4968e-01, 4.9130e-01,
        6.0384e-01, 6.1030e-01, 6.5871e-01, 6.2841e-01, 4.4143e-01,
        1.9048e-01, 7.4018e-02, 3.5332e-02),
      T(1.4604e-03, 1.2570e-03, 1.9961e-03, 2.3598e-03, 5.9267e-03,
        8.0931e-03, 1.4601e-02, 2.0643e-02, 3.7449e-02, 4.3391e-02,
        6.2745e-02, 7.7446e-02, 1.2635e-01, 1.9466e-01, 2.7487e-01,
        3.7428e-01, 4.5982e-01, 4.7172e-01, 4.4790e-01, 3.9635e-01,
        4.8646e-01, 4.6517e-01, 4.6141e-01, 3.2603e-01, 1.8215e-01,
        7.3791e-02, 3.6567e-02, 2.0175e-02),
      T(5.9303e-03, 6.6179e-03, 1.1214e-02, 1.6247e-02, 3.0351e-02,
        4.4109e-02, 6.2478e-02, 7.9755e-02, 9.6626e-02, 9.4567e-02,
        1.0874e-01, 1.1744e-01, 1.6492e-01, 2.2267e-01, 3.1359e-01,
        3.9987e-01, 4.4468e-01, 4.4507e-01, 4.1509e-01, 3.5315e-01,
        3.8601e-01, 3.3181e-01, 2.4343e-01, 1.3579e-01, 7.4115e-02,
        3.4047e-02, 2.3351e-02, 1.4313e-02),
      T(2.1295e-02, 2.8350e-02, 5.5673e-02, 6.9987e-02, 9.1978e-02,
        1.3653e-01, 1.4478e-01, 1.6779e-01, 1.9329e-01, 1.7208e-01,
        1.8805e-01, 1.9608e-01, 2.2581e-01, 2.9534e-01, 3.1215e-01,
        3.4894e-01, 2.7688e-01, 2.3820e-01, 2.2527e-01, 1.9959e-01,
        1.8015e-01, 1.4319e-01, 8.3902e-02, 5.3386e-02, 3.3750e-02,
        1.8162e-02, 1.8458e-02, 1.2847e-02),
      T(3.0469e-02, 3.5307e-02, 7.7832e-02, 9.4903e-02, 1.5087e-01,
        2.1573e-01, 2.9154e-01, 3.1367e-01, 3.8083e-01, 3.6850e-01,
        4.0402e-01, 4.5041e-01, 4.5721e-01, 5.5601e-01, 5.2863e-01,
        5.4976e-01, 4.0354e-01, 3.3515e-01, 3.0731e-01, 2.5419e-01,
        2.1781e-01, 1.6374e-01, 1.2298e-01, 7.7298e-02, 4.6294e-02,
        2.3752e-02, 2.0401e-02, 1.2909e-02),
      T(2.9071e-02, 4.1723e-02, 7.9149e-02, 1.4050e-01, 2.9306e-01,
        5.1104e-01, 6.6809e-01, 7.1677e-01, 7.6009e-01, 7.6077e-01,
        7.7978e-01, 8.0736e-01, 8.2089e-01, 8.5746e-01, 8.5850e-01,
        8.6628e-01, 8.0307e-01, 7.8278e-01, 6.9163e-01, 6.8256e-01,
        6.7340e-01, 5.7951e-01, 5.1666e-01, 3.2986e-01, 1.6927e-01,
        5.2513e-02, 3.0492e-02, 1.5463e-02),
      T(3.4533e-02, 4.8020e-02, 1.2032e-01, 2.4137e-01, 6.0096e-01,
        8.0251e-01, 8.8464e-01, 9.0904e-01, 9.1911e-01, 9.2781e-01,
        9.3747e-01, 9.4583e-01, 9.5007e-01, 9.5779e-01, 9.6114e-01,
        9.6043e-01, 9.5404e-01, 9.4383e-01, 9.2775e-01, 9.2331e-01,
        9.0956e-01, 8.8537e-01, 8.2962e-01, 7.0801e-01, 2.9882e-01,
        9.1867e-02, 3.4787e-02, 1.6245e-02),
      T(3.4896e-02, 5.6930e-02, 1.4412e-01, 3.6995e-01, 7.1463e-01,
        8.7814e-01, 9.2850e-01, 9.3653e-01, 9.4908e-01, 9.5386e-01,
        9.6158e-01, 9.6472e-01, 9.6320e-01, 9.6544e-01, 9.6580e-01,
        9.6449e-01, 9.5944e-01, 9.5484e-01, 9.5333e-01, 9.4281e-01,
        9.5893e-01, 9.4436e-01, 9.0984e-01, 7.7387e-01, 3.1403e-01,
        7.1007e-02, 2.1945e-02, 1.0809e-02),
      T(4.4868e-02, 7.4989e-02, 2.1560e-01, 5.2291e-01, 8.1661e-01,
        9.1452e-01, 9.4504e-01, 9.5013e-01, 9.5396e-01, 9.5815e-01,
        9.6116e-01, 9.6114e-01, 9.5929e-01, 9.5765e-01, 9.6087e-01,
        9.5712e-01, 9.5256e-01, 9.4704e-01, 9.4440e-01, 9.3279e-01,
        9.6347e-01, 9.5107e-01, 9.1002e-01, 7.5917e-01, 2.1720e-01,
        5.6064e-02, 2.3498e-02, 1.1083e-02),
      T(7.7550e-02, 1.3681e-01, 3.2038e-01, 6.3215e-01, 8.2809e-01,
        8.9066e-01, 8.9183e-01, 8.8996e-01, 7.7995e-01, 7.8508e-01,
        7.6737e-01, 7.9057e-01, 7.3225e-01, 7.7120e-01, 7.2414e-01,
        7.4957e-01, 6.6325e-01, 6.9354e-01, 6.3172e-01, 6.5299e-01,
        8.4520e-01, 8.1888e-01, 7.9047e-01, 4.1030e-01, 1.1323e-01,
        4.6366e-02, 1.8671e-02, 1.2663e-02),
      T(9.8263e-02, 1.8164e-01, 4.3265e-01, 7.3340e-01, 8.4517e-01,
        8.8330e-01, 8.7223e-01, 8.4796e-01, 7.0618e-01, 6.7429e-01,
        6.8330e-01, 6.5807e-01, 6.3468e-01, 6.2422e-01, 6.1901e-01,
        6.0265e-01, 5.3608e-01, 5.3792e-01, 5.1256e-01, 5.1631e-01,
        7.7521e-01, 7.3053e-01, 5.6897e-01, 1.8825e-01, 5.7340e-02,
        2.7946e-02, 1.9292e-02, 1.3273e-02),
      T(1.2515e-01, 2.6012e-01, 5.8105e-01, 7.9504e-01, 8.7019e-01,
        8.9241e-01, 8.8640e-01, 8.9073e-01, 7.4305e-01, 7.6426e-01,
        7.1546e-01, 7.3403e-01, 6.5637e-01, 6.7678e-01, 6.9244e-01,
        6.9171e-01, 6.7243e-01, 6.8381e-01, 6.6941e-01, 6.9703e-01,
        8.1285e-01, 6.9987e-01, 4.5697e-01, 1.2757e-01, 3.5441e-02,
        2.6368e-02, 2.3072e-02, 2.6452e-02),
      T(1.6706e-01, 3.4245e-01, 6.8553e-01, 8.3924e-01, 8.8395e-01,
        8.8617e-01, 8.8806e-01, 8.7181e-01, 7.5056e-01, 7.3379e-01,
        7.3424e-01, 7.1409e-01, 6.6733e-01, 6.5400e-01, 6.6427e-01,
        6.4249e-01, 5.9861e-01, 5.9251e-01, 6.1464e-01, 6.2991e-01,
        7.7426e-01, 6.3643e-01, 3.5219e-01, 9.7489e-02, 3.0105e-02,
        2.2138e-02, 2.0397e-02, 2.0346e-02),
      T(2.6283e-01, 4.9972e-01, 7.8121e-01, 8.6183e-01, 8.5866e-01,
        8.7330e-01, 8.2221e-01, 8.3016e-01, 6.3395e-01, 6.6521e-01,
        7.3249e-01, 7.3808e-01, 7.5634e-01, 7.4819e-01, 7.0494e-01,
        6.7100e-01, 5.3396e-01, 5.4660e-01, 5.3508e-01, 5.7070e-01,
        7.2617e-01, 5.1958e-01, 2.5431e-01, 8.5448e-02, 4.2543e-02,
        3.6853e-02, 2.6910e-02, 3.0950e-02),
      T(3.1833e-01, 5.4807e-01, 7.9297e-01, 8.5295e-01, 8.4800e-01,
        8.4096e-01, 8.0479e-01, 7.7077e-01, 5.9931e-01, 5.6310e-01,
        6.8010e-01, 6.3572e-01, 6.9430e-01, 6.4745e-01, 6.4169e-01,
        5.7040e-01, 5.1369e-01, 4.9333e-01, 5.4481e-01, 5.4363e-01,
        6.7796e-01, 4.3270e-01, 1.4516e-01, 5.0843e-02, 2.2773e-02,
        1.8443e-02, 1.5043e-02, 1.4516e-02),
      T(3.4615e-01, 5.0847e-01, 7.2972e-01, 8.0083e-01, 7.5170e-01,
        7.4097e-01, 6.0599e-01, 5.7648e-01, 4.0951e-01, 3.9575e-01,
        4.2222e-01, 4.0706e-01, 3.9518e-01, 3.8708e-01, 3.6376e-01,
        3.6302e-01, 3.2241e-01, 3.7725e-01, 5.5631e-01, 5.7414e-01,
        6.3659e-01, 3.2865e-01, 7.5898e-02, 2.6716e-02, 1.3944e-02,
        1.1860e-02, 1.4716e-02, 1.7905e-02),
      T(3.2063e-01, 4.5822e-01, 6.7359e-01, 7.3385e-01, 6.9173e-01,
        6.3816e-01, 5.5046e-01, 4.6633e-01, 3.6612e-01, 3.0594e-01,
        3.6013e-01, 3.0995e-01, 3.4988e-01, 3.1621e-01, 3.6424e-01,
        3.3739e-01, 3.6879e-01, 3.7739e-01, 5.5614e-01, 5.2886e-01,
        5.3811e-01, 2.6981e-01, 6.9401e-02, 2.5807e-02, 1.4949e-02,
        1.1628e-02, 1.7100e-02, 1.7004e-02))))

    val expectedMask = Tensor[Float](
      T(T(T(0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00),
        T(0.0000e+00, 4.6341e-04, 3.0892e-04, 5.5805e-05, 5.3648e-05,
          3.8348e-05, 4.0923e-05, 4.0874e-05, 4.9342e-05, 1.4934e-04,
          2.3377e-04, 9.2455e-04, 1.9640e-03, 6.7012e-03, 1.1700e-02,
          2.2868e-02, 3.4102e-02, 5.0373e-02, 8.3922e-02, 1.3713e-01,
          2.3499e-01, 3.7590e-01, 4.8422e-01, 5.4733e-01, 4.8918e-01,
          3.3834e-01, 2.3584e-01, 1.9745e-01, 1.6000e-01, 0.0000e+00),
        T(0.0000e+00, 4.2732e-04, 2.9206e-04, 6.0863e-05, 6.0809e-05,
          4.2969e-05, 4.7592e-05, 4.0687e-05, 5.4618e-05, 1.4295e-04,
          2.6305e-04, 8.7722e-04, 2.1579e-03, 6.4814e-03, 1.2199e-02,
          2.1211e-02, 3.3435e-02, 5.0712e-02, 9.8141e-02, 1.7841e-01,
          3.3267e-01, 4.7087e-01, 5.6134e-01, 5.4585e-01, 4.3256e-01,
          2.2894e-01, 1.4579e-01, 1.1617e-01, 9.4591e-02, 0.0000e+00),
        T(0.0000e+00, 7.4229e-05, 4.9629e-05, 1.1812e-05, 1.1427e-05,
          1.3852e-05, 1.4571e-05, 1.6429e-05, 2.0885e-05, 7.9878e-05,
          1.4078e-04, 6.3389e-04, 1.6315e-03, 4.8276e-03, 9.6609e-03,
          1.8357e-02, 2.9629e-02, 6.4242e-02, 1.3947e-01, 2.9693e-01,
          5.0719e-01, 6.8341e-01, 7.3825e-01, 7.0431e-01, 5.7563e-01,
          3.4927e-01, 2.0407e-01, 1.4150e-01, 1.1583e-01, 0.0000e+00),
        T(0.0000e+00, 8.0966e-05, 5.7955e-05, 1.3771e-05, 1.4560e-05,
          1.7485e-05, 2.0353e-05, 1.9813e-05, 3.0120e-05, 8.6005e-05,
          1.9037e-04, 6.0123e-04, 1.7777e-03, 4.5884e-03, 1.0188e-02,
          1.9338e-02, 3.4767e-02, 6.8911e-02, 1.6141e-01, 3.1799e-01,
          5.5213e-01, 6.9518e-01, 7.3970e-01, 6.8841e-01, 5.5608e-01,
          3.4583e-01, 2.1902e-01, 1.3583e-01, 1.0586e-01, 0.0000e+00),
        T(0.0000e+00, 3.6981e-05, 2.3346e-05, 7.2523e-06, 6.9358e-06,
          1.3612e-05, 1.5485e-05, 2.5761e-05, 3.4787e-05, 1.2198e-04,
          2.2105e-04, 6.6305e-04, 1.7468e-03, 4.2893e-03, 9.8238e-03,
          2.0705e-02, 3.8232e-02, 8.9242e-02, 2.1058e-01, 4.1479e-01,
          6.3925e-01, 7.2720e-01, 7.2505e-01, 6.1903e-01, 5.4229e-01,
          3.9588e-01, 2.4779e-01, 1.7973e-01, 1.3406e-01, 0.0000e+00),
        T(0.0000e+00, 4.8939e-05, 3.4500e-05, 1.0843e-05, 1.2283e-05,
          2.0171e-05, 2.7103e-05, 3.6343e-05, 6.3062e-05, 1.7241e-04,
          4.1421e-04, 8.6098e-04, 2.7469e-03, 5.3915e-03, 1.4367e-02,
          2.7193e-02, 5.7192e-02, 1.1829e-01, 2.8904e-01, 4.8999e-01,
          6.8236e-01, 6.9587e-01, 6.6666e-01, 5.4644e-01, 5.2509e-01,
          4.7553e-01, 3.8484e-01, 3.1775e-01, 2.3912e-01, 0.0000e+00),
        T(0.0000e+00, 6.2084e-05, 3.9022e-05, 1.4060e-05, 1.4152e-05,
          2.7991e-05, 3.2111e-05, 6.1916e-05, 8.8266e-05, 3.1988e-04,
          6.1125e-04, 1.5244e-03, 3.8437e-03, 9.7983e-03, 2.1962e-02,
          5.3569e-02, 1.0839e-01, 2.3466e-01, 4.2930e-01, 6.5016e-01,
          7.1807e-01, 7.1723e-01, 6.6036e-01, 6.6802e-01, 6.3845e-01,
          6.4161e-01, 6.2048e-01, 5.2979e-01, 4.4045e-01, 0.0000e+00),
        T(0.0000e+00, 9.1347e-05, 6.4619e-05, 2.5321e-05, 3.1816e-05,
          5.1436e-05, 7.6462e-05, 1.1214e-04, 2.2407e-04, 6.1354e-04,
          1.5753e-03, 2.8594e-03, 8.4160e-03, 1.7025e-02, 4.0972e-02,
          9.4575e-02, 1.9026e-01, 3.7013e-01, 5.5772e-01, 6.8750e-01,
          7.2380e-01, 6.9485e-01, 6.5762e-01, 6.7078e-01, 6.5950e-01,
          6.4230e-01, 6.2810e-01, 5.1840e-01, 4.1623e-01, 0.0000e+00),
        T(0.0000e+00, 8.7828e-05, 6.6269e-05, 3.6323e-05, 4.4775e-05,
          1.1606e-04, 1.4916e-04, 3.7401e-04, 6.2966e-04, 2.2745e-03,
          4.3958e-03, 8.7915e-03, 1.6948e-02, 3.0861e-02, 6.1891e-02,
          1.3839e-01, 2.8432e-01, 4.8105e-01, 6.2043e-01, 7.0035e-01,
          7.0787e-01, 7.0818e-01, 6.6805e-01, 6.9580e-01, 6.7569e-01,
          6.0427e-01, 5.3689e-01, 4.2307e-01, 2.7888e-01, 0.0000e+00),
        T(0.0000e+00, 1.3902e-04, 1.1468e-04, 7.6237e-05, 1.1698e-04,
          2.3893e-04, 4.1147e-04, 8.1630e-04, 1.9367e-03, 5.3219e-03,
          1.3054e-02, 1.7966e-02, 3.7152e-02, 5.5747e-02, 1.1024e-01,
          2.4388e-01, 4.2369e-01, 5.9124e-01, 6.9195e-01, 7.2445e-01,
          7.2798e-01, 7.3068e-01, 7.0324e-01, 7.3541e-01, 7.3432e-01,
          6.6021e-01, 5.4254e-01, 2.8755e-01, 1.6474e-01, 0.0000e+00),
        T(0.0000e+00, 2.8135e-04, 2.1398e-04, 2.1649e-04, 2.7242e-04,
          7.0205e-04, 9.5946e-04, 2.1251e-03, 3.9960e-03, 1.1550e-02,
          1.8662e-02, 2.4886e-02, 3.7426e-02, 5.9397e-02, 1.1954e-01,
          2.3302e-01, 3.8706e-01, 4.9049e-01, 5.7261e-01, 5.8114e-01,
          5.4481e-01, 6.3964e-01, 6.6289e-01, 7.0789e-01, 6.9167e-01,
          5.9608e-01, 3.2595e-01, 1.3987e-01, 6.1413e-02, 0.0000e+00),
        T(0.0000e+00, 5.2232e-04, 4.4520e-04, 4.3554e-04, 7.0351e-04,
          1.4864e-03, 2.7261e-03, 5.5355e-03, 1.2103e-02, 2.5020e-02,
          4.1414e-02, 4.1824e-02, 6.2823e-02, 9.2860e-02, 1.6066e-01,
          2.9213e-01, 4.1854e-01, 4.8238e-01, 5.5534e-01, 5.4968e-01,
          4.9130e-01, 6.0384e-01, 6.1030e-01, 6.5871e-01, 6.2841e-01,
          4.4143e-01, 1.9048e-01, 7.4018e-02, 3.5332e-02, 0.0000e+00),
        T(0.0000e+00, 1.4604e-03, 1.2570e-03, 1.9961e-03, 2.3598e-03,
          5.9267e-03, 8.0931e-03, 1.4601e-02, 2.0643e-02, 3.7449e-02,
          4.3391e-02, 6.2745e-02, 7.7446e-02, 1.2635e-01, 1.9466e-01,
          2.7487e-01, 3.7428e-01, 4.5982e-01, 4.7172e-01, 4.4790e-01,
          3.9635e-01, 4.8646e-01, 4.6517e-01, 4.6141e-01, 3.2603e-01,
          1.8215e-01, 7.3791e-02, 3.6567e-02, 2.0175e-02, 0.0000e+00),
        T(0.0000e+00, 5.9303e-03, 6.6179e-03, 1.1214e-02, 1.6247e-02,
          3.0351e-02, 4.4109e-02, 6.2478e-02, 7.9755e-02, 9.6626e-02,
          9.4567e-02, 1.0874e-01, 1.1744e-01, 1.6492e-01, 2.2267e-01,
          3.1359e-01, 3.9987e-01, 4.4468e-01, 4.4507e-01, 4.1509e-01,
          3.5315e-01, 3.8601e-01, 3.3181e-01, 2.4343e-01, 1.3579e-01,
          7.4115e-02, 3.4047e-02, 2.3351e-02, 1.4313e-02, 0.0000e+00),
        T(0.0000e+00, 2.1295e-02, 2.8350e-02, 5.5673e-02, 6.9987e-02,
          9.1978e-02, 1.3653e-01, 1.4478e-01, 1.6779e-01, 1.9329e-01,
          1.7208e-01, 1.8805e-01, 1.9608e-01, 2.2581e-01, 2.9534e-01,
          3.1215e-01, 3.4894e-01, 2.7688e-01, 2.3820e-01, 2.2527e-01,
          1.9959e-01, 1.8015e-01, 1.4319e-01, 8.3902e-02, 5.3386e-02,
          3.3750e-02, 1.8162e-02, 1.8458e-02, 1.2847e-02, 0.0000e+00),
        T(0.0000e+00, 3.0469e-02, 3.5307e-02, 7.7832e-02, 9.4903e-02,
          1.5087e-01, 2.1573e-01, 2.9154e-01, 3.1367e-01, 3.8083e-01,
          3.6850e-01, 4.0402e-01, 4.5041e-01, 4.5721e-01, 5.5601e-01,
          5.2863e-01, 5.4976e-01, 4.0354e-01, 3.3515e-01, 3.0731e-01,
          2.5419e-01, 2.1781e-01, 1.6374e-01, 1.2298e-01, 7.7298e-02,
          4.6294e-02, 2.3752e-02, 2.0401e-02, 1.2909e-02, 0.0000e+00),
        T(0.0000e+00, 2.9071e-02, 4.1723e-02, 7.9149e-02, 1.4050e-01,
          2.9306e-01, 5.1104e-01, 6.6809e-01, 7.1677e-01, 7.6009e-01,
          7.6077e-01, 7.7978e-01, 8.0736e-01, 8.2089e-01, 8.5746e-01,
          8.5850e-01, 8.6628e-01, 8.0307e-01, 7.8278e-01, 6.9163e-01,
          6.8256e-01, 6.7340e-01, 5.7951e-01, 5.1666e-01, 3.2986e-01,
          1.6927e-01, 5.2513e-02, 3.0492e-02, 1.5463e-02, 0.0000e+00),
        T(0.0000e+00, 3.4533e-02, 4.8020e-02, 1.2032e-01, 2.4137e-01,
          6.0096e-01, 8.0251e-01, 8.8464e-01, 9.0904e-01, 9.1911e-01,
          9.2781e-01, 9.3747e-01, 9.4583e-01, 9.5007e-01, 9.5779e-01,
          9.6114e-01, 9.6043e-01, 9.5404e-01, 9.4383e-01, 9.2775e-01,
          9.2331e-01, 9.0956e-01, 8.8537e-01, 8.2962e-01, 7.0801e-01,
          2.9882e-01, 9.1867e-02, 3.4787e-02, 1.6245e-02, 0.0000e+00),
        T(0.0000e+00, 3.4896e-02, 5.6930e-02, 1.4412e-01, 3.6995e-01,
          7.1463e-01, 8.7814e-01, 9.2850e-01, 9.3653e-01, 9.4908e-01,
          9.5386e-01, 9.6158e-01, 9.6472e-01, 9.6320e-01, 9.6544e-01,
          9.6580e-01, 9.6449e-01, 9.5944e-01, 9.5484e-01, 9.5333e-01,
          9.4281e-01, 9.5893e-01, 9.4436e-01, 9.0984e-01, 7.7387e-01,
          3.1403e-01, 7.1007e-02, 2.1945e-02, 1.0809e-02, 0.0000e+00),
        T(0.0000e+00, 4.4868e-02, 7.4989e-02, 2.1560e-01, 5.2291e-01,
          8.1661e-01, 9.1452e-01, 9.4504e-01, 9.5013e-01, 9.5396e-01,
          9.5815e-01, 9.6116e-01, 9.6114e-01, 9.5929e-01, 9.5765e-01,
          9.6087e-01, 9.5712e-01, 9.5256e-01, 9.4704e-01, 9.4440e-01,
          9.3279e-01, 9.6347e-01, 9.5107e-01, 9.1002e-01, 7.5917e-01,
          2.1720e-01, 5.6064e-02, 2.3498e-02, 1.1083e-02, 0.0000e+00),
        T(0.0000e+00, 7.7550e-02, 1.3681e-01, 3.2038e-01, 6.3215e-01,
          8.2809e-01, 8.9066e-01, 8.9183e-01, 8.8996e-01, 7.7995e-01,
          7.8508e-01, 7.6737e-01, 7.9057e-01, 7.3225e-01, 7.7120e-01,
          7.2414e-01, 7.4957e-01, 6.6325e-01, 6.9354e-01, 6.3172e-01,
          6.5299e-01, 8.4520e-01, 8.1888e-01, 7.9047e-01, 4.1030e-01,
          1.1323e-01, 4.6366e-02, 1.8671e-02, 1.2663e-02, 0.0000e+00),
        T(0.0000e+00, 9.8263e-02, 1.8164e-01, 4.3265e-01, 7.3340e-01,
          8.4517e-01, 8.8330e-01, 8.7223e-01, 8.4796e-01, 7.0618e-01,
          6.7429e-01, 6.8330e-01, 6.5807e-01, 6.3468e-01, 6.2422e-01,
          6.1901e-01, 6.0265e-01, 5.3608e-01, 5.3792e-01, 5.1256e-01,
          5.1631e-01, 7.7521e-01, 7.3053e-01, 5.6897e-01, 1.8825e-01,
          5.7340e-02, 2.7946e-02, 1.9292e-02, 1.3273e-02, 0.0000e+00),
        T(0.0000e+00, 1.2515e-01, 2.6012e-01, 5.8105e-01, 7.9504e-01,
          8.7019e-01, 8.9241e-01, 8.8640e-01, 8.9073e-01, 7.4305e-01,
          7.6426e-01, 7.1546e-01, 7.3403e-01, 6.5637e-01, 6.7678e-01,
          6.9244e-01, 6.9171e-01, 6.7243e-01, 6.8381e-01, 6.6941e-01,
          6.9703e-01, 8.1285e-01, 6.9987e-01, 4.5697e-01, 1.2757e-01,
          3.5441e-02, 2.6368e-02, 2.3072e-02, 2.6452e-02, 0.0000e+00),
        T(0.0000e+00, 1.6706e-01, 3.4245e-01, 6.8553e-01, 8.3924e-01,
          8.8395e-01, 8.8617e-01, 8.8806e-01, 8.7181e-01, 7.5056e-01,
          7.3379e-01, 7.3424e-01, 7.1409e-01, 6.6733e-01, 6.5400e-01,
          6.6427e-01, 6.4249e-01, 5.9861e-01, 5.9251e-01, 6.1464e-01,
          6.2991e-01, 7.7426e-01, 6.3643e-01, 3.5219e-01, 9.7489e-02,
          3.0105e-02, 2.2138e-02, 2.0397e-02, 2.0346e-02, 0.0000e+00),
        T(0.0000e+00, 2.6283e-01, 4.9972e-01, 7.8121e-01, 8.6183e-01,
          8.5866e-01, 8.7330e-01, 8.2221e-01, 8.3016e-01, 6.3395e-01,
          6.6521e-01, 7.3249e-01, 7.3808e-01, 7.5634e-01, 7.4819e-01,
          7.0494e-01, 6.7100e-01, 5.3396e-01, 5.4660e-01, 5.3508e-01,
          5.7070e-01, 7.2617e-01, 5.1958e-01, 2.5431e-01, 8.5448e-02,
          4.2543e-02, 3.6853e-02, 2.6910e-02, 3.0950e-02, 0.0000e+00),
        T(0.0000e+00, 3.1833e-01, 5.4807e-01, 7.9297e-01, 8.5295e-01,
          8.4800e-01, 8.4096e-01, 8.0479e-01, 7.7077e-01, 5.9931e-01,
          5.6310e-01, 6.8010e-01, 6.3572e-01, 6.9430e-01, 6.4745e-01,
          6.4169e-01, 5.7040e-01, 5.1369e-01, 4.9333e-01, 5.4481e-01,
          5.4363e-01, 6.7796e-01, 4.3270e-01, 1.4516e-01, 5.0843e-02,
          2.2773e-02, 1.8443e-02, 1.5043e-02, 1.4516e-02, 0.0000e+00),
        T(0.0000e+00, 3.4615e-01, 5.0847e-01, 7.2972e-01, 8.0083e-01,
          7.5170e-01, 7.4097e-01, 6.0599e-01, 5.7648e-01, 4.0951e-01,
          3.9575e-01, 4.2222e-01, 4.0706e-01, 3.9518e-01, 3.8708e-01,
          3.6376e-01, 3.6302e-01, 3.2241e-01, 3.7725e-01, 5.5631e-01,
          5.7414e-01, 6.3659e-01, 3.2865e-01, 7.5898e-02, 2.6716e-02,
          1.3944e-02, 1.1860e-02, 1.4716e-02, 1.7905e-02, 0.0000e+00),
        T(0.0000e+00, 3.2063e-01, 4.5822e-01, 6.7359e-01, 7.3385e-01,
          6.9173e-01, 6.3816e-01, 5.5046e-01, 4.6633e-01, 3.6612e-01,
          3.0594e-01, 3.6013e-01, 3.0995e-01, 3.4988e-01, 3.1621e-01,
          3.6424e-01, 3.3739e-01, 3.6879e-01, 3.7739e-01, 5.5614e-01,
          5.2886e-01, 5.3811e-01, 2.6981e-01, 6.9401e-02, 2.5807e-02,
          1.4949e-02, 1.1628e-02, 1.7100e-02, 1.7004e-02, 0.0000e+00),
        T(0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
          0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
          0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
          0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
          0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
          0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00))))

    val out = Utils.expandMasks(mask, padding = 1)

    out._1 should be(expectedMask)
    out._2 should be(1.0714285f)
  }

  "bilinear" should "be ok" in {
    val input = Tensor[Float](T(T(T(0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
      0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
      0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
      0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
      0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
      0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00),
      T(0.0000e+00, 1.2962e-04, 1.5965e-04, 7.5651e-05, 1.2463e-04,
        5.3859e-04, 1.8520e-03, 1.6062e-02, 1.1791e-01, 4.9596e-01,
        8.2137e-01, 9.5361e-01, 9.7020e-01, 9.7749e-01, 9.6899e-01,
        8.7968e-01, 4.8902e-01, 1.3723e-01, 3.2094e-02, 4.2613e-03,
        1.4644e-03, 3.7567e-04, 2.8523e-04, 3.3454e-04, 3.5013e-04,
        7.2901e-04, 7.2081e-04, 2.1143e-03, 2.1492e-03, 0.0000e+00),
      T(0.0000e+00, 1.2368e-04, 1.3051e-04, 7.9764e-05, 1.2630e-04,
        5.3688e-04, 2.0936e-03, 1.6497e-02, 1.8402e-01, 6.7172e-01,
        9.3169e-01, 9.8511e-01, 9.8917e-01, 9.9411e-01, 9.9247e-01,
        9.8259e-01, 9.0712e-01, 5.2733e-01, 1.1831e-01, 2.2569e-02,
        5.7950e-03, 1.5129e-03, 1.2669e-03, 1.1600e-03, 1.1658e-03,
        1.8827e-03, 1.6837e-03, 3.3666e-03, 3.0893e-03, 0.0000e+00),
      T(0.0000e+00, 4.5270e-05, 7.1242e-05, 4.7483e-05, 9.4083e-05,
        4.3131e-04, 1.9557e-03, 1.5055e-02, 1.6355e-01, 7.1506e-01,
        9.3117e-01, 9.7436e-01, 9.8423e-01, 9.9045e-01, 9.9206e-01,
        9.8907e-01, 9.6861e-01, 8.1751e-01, 3.9729e-01, 1.3331e-01,
        4.4435e-02, 7.6750e-03, 3.8214e-03, 1.2493e-03, 8.1321e-04,
        6.6052e-04, 3.9533e-04, 7.5716e-04, 5.2089e-04, 0.0000e+00),
      T(0.0000e+00, 5.9879e-05, 8.9897e-05, 7.1788e-05, 1.6429e-04,
        5.3231e-04, 2.3130e-03, 9.0313e-03, 8.5725e-02, 3.8716e-01,
        7.7866e-01, 9.2478e-01, 9.6391e-01, 9.8125e-01, 9.8626e-01,
        9.8746e-01, 9.7946e-01, 9.4428e-01, 8.2930e-01, 5.2393e-01,
        1.9581e-01, 3.1319e-02, 5.9265e-03, 1.2291e-03, 4.2470e-04,
        2.3979e-04, 1.0690e-04, 2.5030e-04, 2.1177e-04, 0.0000e+00),
      T(0.0000e+00, 4.9742e-05, 8.0955e-05, 6.6765e-05, 1.5642e-04,
        4.7650e-04, 1.5499e-03, 5.7057e-03, 4.1489e-02, 1.8026e-01,
        5.3028e-01, 7.5347e-01, 9.1154e-01, 9.5575e-01, 9.8576e-01,
        9.9361e-01, 9.9608e-01, 9.9646e-01, 9.9364e-01, 9.7658e-01,
        8.2899e-01, 4.2312e-01, 9.3778e-02, 1.2634e-02, 2.4736e-03,
        3.8372e-04, 1.7237e-04, 1.1105e-04, 9.7070e-05, 0.0000e+00),
      T(0.0000e+00, 8.1171e-05, 1.2716e-04, 1.0171e-04, 2.8292e-04,
        5.8469e-04, 1.8916e-03, 5.2022e-03, 3.1568e-02, 1.3417e-01,
        4.2515e-01, 6.9434e-01, 8.9302e-01, 9.6706e-01, 9.8842e-01,
        9.9689e-01, 9.9789e-01, 9.9885e-01, 9.9868e-01, 9.9708e-01,
        9.9015e-01, 9.3936e-01, 5.8068e-01, 1.1171e-01, 1.1223e-02,
        1.4602e-03, 3.9804e-04, 2.1332e-04, 1.5545e-04, 0.0000e+00),
      T(0.0000e+00, 1.0366e-04, 1.6457e-04, 1.5500e-04, 3.2252e-04,
        9.2322e-04, 2.4091e-03, 6.5742e-03, 3.3120e-02, 1.3465e-01,
        3.5262e-01, 6.4416e-01, 8.6037e-01, 9.3453e-01, 9.7787e-01,
        9.8996e-01, 9.9605e-01, 9.9809e-01, 9.9854e-01, 9.9807e-01,
        9.9663e-01, 9.9213e-01, 9.4657e-01, 6.3826e-01, 1.2039e-01,
        1.1152e-02, 2.7762e-03, 9.0152e-04, 6.2426e-04, 0.0000e+00),
      T(0.0000e+00, 1.9249e-04, 2.9557e-04, 2.3550e-04, 5.3418e-04,
        1.1303e-03, 3.7646e-03, 1.0936e-02, 5.8011e-02, 1.8411e-01,
        4.4272e-01, 7.2828e-01, 8.6077e-01, 9.1749e-01, 9.6224e-01,
        9.8126e-01, 9.9317e-01, 9.9811e-01, 9.9854e-01, 9.9862e-01,
        9.9792e-01, 9.9698e-01, 9.9017e-01, 9.1087e-01, 4.2813e-01,
        5.0245e-02, 6.9499e-03, 1.6183e-03, 9.4231e-04, 0.0000e+00),
      T(0.0000e+00, 5.4746e-04, 6.4209e-04, 6.1998e-04, 1.1733e-03,
        2.9278e-03, 9.4354e-03, 2.7926e-02, 1.3199e-01, 3.1125e-01,
        5.8159e-01, 7.7794e-01, 8.8439e-01, 8.9998e-01, 9.5471e-01,
        9.6995e-01, 9.9235e-01, 9.9761e-01, 9.9862e-01, 9.9858e-01,
        9.9857e-01, 9.9752e-01, 9.9419e-01, 9.6218e-01, 5.8138e-01,
        9.4702e-02, 1.4433e-02, 2.4684e-03, 1.4372e-03, 0.0000e+00),
      T(0.0000e+00, 1.4431e-03, 2.1270e-03, 2.1014e-03, 4.7153e-03,
        1.3852e-02, 4.0739e-02, 9.3498e-02, 3.0845e-01, 5.3479e-01,
        7.2163e-01, 8.4289e-01, 8.9133e-01, 9.0804e-01, 9.3960e-01,
        9.7547e-01, 9.9190e-01, 9.9787e-01, 9.9862e-01, 9.9877e-01,
        9.9879e-01, 9.9817e-01, 9.9635e-01, 9.8088e-01, 8.2198e-01,
        2.2577e-01, 2.5690e-02, 4.3012e-03, 2.0275e-03, 0.0000e+00),
      T(0.0000e+00, 8.4658e-03, 1.4178e-02, 1.8087e-02, 4.6691e-02,
        1.0853e-01, 2.4585e-01, 3.8286e-01, 5.6033e-01, 7.4550e-01,
        8.2052e-01, 8.7372e-01, 9.2813e-01, 9.2598e-01, 9.7223e-01,
        9.9068e-01, 9.9678e-01, 9.9816e-01, 9.9866e-01, 9.9877e-01,
        9.9882e-01, 9.9765e-01, 9.9663e-01, 9.9055e-01, 9.3603e-01,
        4.9772e-01, 9.3717e-02, 1.3700e-02, 6.6240e-03, 0.0000e+00),
      T(0.0000e+00, 7.2381e-02, 1.4160e-01, 2.0312e-01, 3.5265e-01,
        5.8949e-01, 6.2425e-01, 6.5431e-01, 6.5858e-01, 7.7839e-01,
        8.0269e-01, 8.4453e-01, 8.8800e-01, 9.1791e-01, 9.6894e-01,
        9.9384e-01, 9.9715e-01, 9.9848e-01, 9.9868e-01, 9.9877e-01,
        9.9870e-01, 9.9795e-01, 9.9707e-01, 9.9310e-01, 9.7054e-01,
        7.8018e-01, 2.4557e-01, 5.0973e-02, 1.7686e-02, 0.0000e+00),
      T(0.0000e+00, 8.0073e-02, 1.2308e-01, 1.7152e-01, 2.6257e-01,
        4.3553e-01, 4.5621e-01, 5.5101e-01, 5.5624e-01, 5.9628e-01,
        6.1677e-01, 5.8452e-01, 7.4313e-01, 8.5381e-01, 9.6595e-01,
        9.9030e-01, 9.9581e-01, 9.9733e-01, 9.9792e-01, 9.9847e-01,
        9.9845e-01, 9.9737e-01, 9.9677e-01, 9.9339e-01, 9.8257e-01,
        8.8775e-01, 5.2885e-01, 2.2996e-01, 9.2814e-02, 0.0000e+00),
      T(0.0000e+00, 4.1577e-02, 4.8213e-02, 5.6518e-02, 8.2797e-02,
        1.8809e-01, 2.1246e-01, 2.6011e-01, 2.8504e-01, 3.0879e-01,
        3.0685e-01, 2.9604e-01, 4.3665e-01, 7.0377e-01, 9.2423e-01,
        9.8351e-01, 9.9270e-01, 9.9652e-01, 9.9714e-01, 9.9812e-01,
        9.9798e-01, 9.9726e-01, 9.9656e-01, 9.9363e-01, 9.8390e-01,
        9.2150e-01, 7.0945e-01, 5.2447e-01, 2.6249e-01, 0.0000e+00),
      T(0.0000e+00, 4.3041e-02, 5.7549e-02, 1.0371e-01, 2.0892e-01,
        2.8414e-01, 2.6340e-01, 1.5407e-01, 1.4225e-01, 2.2257e-01,
        2.2046e-01, 1.1707e-01, 1.8171e-01, 3.1578e-01, 6.1651e-01,
        8.3786e-01, 9.2774e-01, 9.5711e-01, 9.7792e-01, 9.9360e-01,
        9.9497e-01, 9.9584e-01, 9.9477e-01, 9.8817e-01, 9.6667e-01,
        8.9339e-01, 6.8557e-01, 5.0704e-01, 3.2797e-01, 0.0000e+00),
      T(0.0000e+00, 4.9168e-02, 7.9762e-02, 1.4255e-01, 3.1908e-01,
        3.2118e-01, 2.9509e-01, 1.2394e-01, 1.1111e-01, 1.9526e-01,
        2.1016e-01, 9.9896e-02, 1.4676e-01, 2.0443e-01, 3.3004e-01,
        4.3146e-01, 6.4772e-01, 7.7439e-01, 9.0822e-01, 9.8362e-01,
        9.9085e-01, 9.9525e-01, 9.9412e-01, 9.8064e-01, 9.2167e-01,
        6.9837e-01, 3.4479e-01, 2.2668e-01, 1.4876e-01, 0.0000e+00),
      T(0.0000e+00, 7.2343e-02, 1.0855e-01, 1.6471e-01, 3.0053e-01,
        2.1082e-01, 1.8731e-01, 1.0162e-01, 1.0489e-01, 2.1044e-01,
        2.2019e-01, 9.6206e-02, 1.5899e-01, 2.5111e-01, 2.6601e-01,
        2.9842e-01, 3.9819e-01, 5.1100e-01, 7.6240e-01, 9.4227e-01,
        9.7923e-01, 9.9100e-01, 9.8955e-01, 9.6678e-01, 8.1539e-01,
        4.1107e-01, 1.6661e-01, 1.1339e-01, 8.8043e-02, 0.0000e+00),
      T(0.0000e+00, 8.3878e-02, 1.5058e-01, 1.8603e-01, 3.0950e-01,
        2.0273e-01, 1.7968e-01, 9.2001e-02, 1.0078e-01, 1.9662e-01,
        2.2166e-01, 8.8923e-02, 1.5904e-01, 2.3219e-01, 2.4331e-01,
        2.8560e-01, 3.1603e-01, 3.9376e-01, 6.5594e-01, 8.6947e-01,
        9.6133e-01, 9.8903e-01, 9.8802e-01, 9.4853e-01, 7.2736e-01,
        2.9465e-01, 1.1399e-01, 8.6427e-02, 6.6437e-02, 0.0000e+00),
      T(0.0000e+00, 1.1361e-01, 1.9206e-01, 1.9744e-01, 2.5881e-01,
        2.3553e-01, 1.9190e-01, 9.0327e-02, 8.4694e-02, 1.8203e-01,
        1.6832e-01, 6.8395e-02, 1.3128e-01, 2.6222e-01, 3.2372e-01,
        3.1692e-01, 3.7027e-01, 3.3007e-01, 5.9151e-01, 8.3698e-01,
        9.5793e-01, 9.8585e-01, 9.8691e-01, 9.4966e-01, 7.1784e-01,
        3.0318e-01, 1.3751e-01, 7.5880e-02, 6.1299e-02, 0.0000e+00),
      T(0.0000e+00, 1.1480e-01, 2.0946e-01, 1.9576e-01, 2.2303e-01,
        2.3028e-01, 1.8244e-01, 1.0421e-01, 1.0533e-01, 1.8064e-01,
        1.9141e-01, 6.0646e-02, 1.2537e-01, 1.9539e-01, 3.1168e-01,
        3.1028e-01, 3.4262e-01, 3.3129e-01, 5.2786e-01, 7.4591e-01,
        9.2666e-01, 9.8106e-01, 9.8336e-01, 9.3733e-01, 7.1442e-01,
        2.8636e-01, 1.3877e-01, 7.7366e-02, 5.6022e-02, 0.0000e+00),
      T(0.0000e+00, 7.2867e-02, 1.2251e-01, 1.5949e-01, 1.7276e-01,
        1.9124e-01, 1.5907e-01, 8.2602e-02, 8.4349e-02, 1.5679e-01,
        1.4966e-01, 6.2945e-02, 1.0368e-01, 1.5672e-01, 2.4730e-01,
        2.9175e-01, 3.5009e-01, 3.3013e-01, 5.6691e-01, 7.8430e-01,
        9.4706e-01, 9.7538e-01, 9.8211e-01, 9.5804e-01, 8.5937e-01,
        4.5496e-01, 2.0237e-01, 1.0152e-01, 7.2687e-02, 0.0000e+00),
      T(0.0000e+00, 4.9442e-02, 7.6667e-02, 7.3187e-02, 8.2513e-02,
        9.7021e-02, 9.1034e-02, 6.4151e-02, 7.2570e-02, 1.2189e-01,
        1.4677e-01, 5.4870e-02, 1.0266e-01, 1.3705e-01, 2.3842e-01,
        2.6176e-01, 3.3107e-01, 3.4387e-01, 5.5684e-01, 7.8205e-01,
        9.4111e-01, 9.7452e-01, 9.8105e-01, 9.5689e-01, 8.7585e-01,
        5.4566e-01, 2.6537e-01, 1.1464e-01, 7.2341e-02, 0.0000e+00),
      T(0.0000e+00, 1.9823e-02, 2.3113e-02, 1.7871e-02, 1.9827e-02,
        2.3113e-02, 2.1277e-02, 1.5889e-02, 1.7244e-02, 3.0173e-02,
        4.5981e-02, 5.3338e-02, 1.1286e-01, 1.7230e-01, 2.6860e-01,
        2.8171e-01, 3.6020e-01, 3.5139e-01, 6.1736e-01, 7.8975e-01,
        9.4838e-01, 9.6199e-01, 9.7300e-01, 9.5711e-01, 9.2493e-01,
        7.2215e-01, 3.8161e-01, 1.6386e-01, 8.9880e-02, 0.0000e+00),
      T(0.0000e+00, 1.1020e-02, 1.1338e-02, 7.6316e-03, 8.8145e-03,
        9.9691e-03, 1.0634e-02, 6.8242e-03, 7.4463e-03, 1.1914e-02,
        1.9584e-02, 3.6592e-02, 9.0816e-02, 1.4934e-01, 2.6871e-01,
        2.4788e-01, 3.3420e-01, 3.5825e-01, 5.9234e-01, 8.1133e-01,
        9.4999e-01, 9.5996e-01, 9.7295e-01, 9.5544e-01, 9.3005e-01,
        7.7938e-01, 4.9505e-01, 2.1431e-01, 1.0007e-01, 0.0000e+00),
      T(0.0000e+00, 6.3023e-03, 5.8030e-03, 3.0986e-03, 3.1009e-03,
        4.9548e-03, 4.4332e-03, 5.4075e-03, 4.9906e-03, 1.1305e-02,
        1.6693e-02, 3.7891e-02, 7.8640e-02, 1.1590e-01, 1.7821e-01,
        2.0496e-01, 3.0353e-01, 3.6439e-01, 6.2596e-01, 8.1887e-01,
        9.5451e-01, 9.5250e-01, 9.6855e-01, 9.4909e-01, 9.3256e-01,
        8.4662e-01, 6.4621e-01, 2.9356e-01, 1.2651e-01, 0.0000e+00),
      T(0.0000e+00, 6.5988e-03, 6.5097e-03, 2.6834e-03, 2.9538e-03,
        3.4488e-03, 4.0199e-03, 3.8142e-03, 4.5138e-03, 6.4854e-03,
        1.2293e-02, 2.4769e-02, 5.9595e-02, 8.2994e-02, 1.5100e-01,
        1.6747e-01, 2.5486e-01, 3.3526e-01, 5.3555e-01, 7.8914e-01,
        9.3644e-01, 9.3533e-01, 9.5888e-01, 9.3445e-01, 9.1532e-01,
        8.3060e-01, 6.8500e-01, 3.7509e-01, 1.5610e-01, 0.0000e+00),
      T(0.0000e+00, 9.3603e-03, 7.3130e-03, 2.2889e-03, 1.8334e-03,
        1.5095e-03, 1.3064e-03, 1.3984e-03, 1.2498e-03, 2.3373e-03,
        4.6787e-03, 1.3369e-02, 3.9303e-02, 5.2740e-02, 1.0400e-01,
        1.0548e-01, 1.3623e-01, 3.4002e-01, 4.1932e-01, 6.8306e-01,
        8.5767e-01, 8.8954e-01, 9.2014e-01, 8.9145e-01, 8.7679e-01,
        7.9980e-01, 7.0315e-01, 4.5124e-01, 2.2822e-01, 0.0000e+00),
      T(0.0000e+00, 7.7092e-03, 5.7172e-03, 1.2502e-03, 1.0234e-03,
        5.9485e-04, 5.7253e-04, 5.5290e-04, 6.1329e-04, 1.1514e-03,
        2.5922e-03, 9.5804e-03, 2.8725e-02, 4.9797e-02, 1.0335e-01,
        1.0158e-01, 1.3878e-01, 2.8591e-01, 3.6244e-01, 5.1836e-01,
        6.9144e-01, 7.3040e-01, 7.7563e-01, 7.5869e-01, 7.0898e-01,
        6.3988e-01, 5.4064e-01, 3.7440e-01, 2.0982e-01, 0.0000e+00),
      T(0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00))))

    val output = Tensor[Float](1, 40, 50)
    Utils.bilinear(input, output)

    val expectedOut = Tensor[Float](T(T(
      T(0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00),
      T(0.0000e+00, 3.2404e-05, 8.1010e-05, 9.2271e-05, 8.9279e-05,
        5.7781e-05, 5.9528e-05, 7.7896e-05, 2.3313e-04, 5.0080e-04,
        9.9333e-04, 4.7100e-03, 1.0039e-02, 4.8233e-02, 1.2095e-01,
        2.6272e-01, 3.9133e-01, 5.1336e-01, 5.6295e-01, 5.9808e-01,
        6.0430e-01, 6.0820e-01, 6.1093e-01, 6.0774e-01, 5.9445e-01,
        5.6096e-01, 4.5213e-01, 3.0564e-01, 1.7372e-01, 7.2629e-02,
        3.3201e-02, 1.3101e-02, 2.6633e-03, 1.6145e-03, 7.7914e-04,
        3.7088e-04, 2.1219e-04, 1.7827e-04, 1.9676e-04, 2.1104e-04,
        2.1688e-04, 3.1355e-04, 4.5563e-04, 4.5256e-04, 6.2469e-04,
        1.1472e-03, 1.3302e-03, 1.3433e-03, 5.3730e-04, 0.0000e+00),
      T(0.0000e+00, 5.0956e-05, 1.2739e-04, 1.4019e-04, 1.3441e-04,
        9.1499e-05, 9.6420e-05, 1.2526e-04, 3.7287e-04, 8.1888e-04,
        1.6617e-03, 7.6557e-03, 1.6225e-02, 9.2113e-02, 2.2654e-01,
        4.7804e-01, 6.8222e-01, 8.6274e-01, 9.2435e-01, 9.6780e-01,
        9.7494e-01, 9.7988e-01, 9.8372e-01, 9.8017e-01, 9.6589e-01,
        9.3017e-01, 8.0928e-01, 6.4581e-01, 4.2843e-01, 2.3970e-01,
        1.0824e-01, 4.3105e-02, 1.1127e-02, 6.3037e-03, 2.6311e-03,
        1.2594e-03, 7.4263e-04, 6.5336e-04, 6.4781e-04, 6.4648e-04,
        6.5361e-04, 8.5825e-04, 1.1616e-03, 1.1138e-03, 1.3823e-03,
        2.2835e-03, 2.5510e-03, 2.5017e-03, 1.0007e-03, 0.0000e+00),
      T(0.0000e+00, 4.5552e-05, 1.1388e-04, 1.1941e-04, 1.1363e-04,
        8.5203e-05, 9.4347e-05, 1.2227e-04, 3.6312e-04, 8.3422e-04,
        1.7658e-03, 7.7725e-03, 1.6317e-02, 1.1541e-01, 2.8060e-01,
        5.7800e-01, 7.7893e-01, 9.3162e-01, 9.6291e-01, 9.8472e-01,
        9.8759e-01, 9.9059e-01, 9.9366e-01, 9.9292e-01, 9.9062e-01,
        9.8520e-01, 9.5596e-01, 9.1480e-01, 7.0408e-01, 4.8152e-01,
        2.3527e-01, 1.0647e-01, 3.6411e-02, 2.0940e-02, 8.9566e-03,
        3.9515e-03, 2.0044e-03, 1.5862e-03, 1.3372e-03, 1.1613e-03,
        1.1316e-03, 1.3650e-03, 1.7299e-03, 1.6056e-03, 1.8262e-03,
        2.7368e-03, 2.9315e-03, 2.7682e-03, 1.1073e-03, 0.0000e+00),
      T(0.0000e+00, 2.2028e-05, 5.5071e-05, 6.9219e-05, 7.3224e-05,
        5.6945e-05, 7.0155e-05, 9.8110e-05, 3.0595e-04, 7.5019e-04,
        1.6672e-03, 7.2777e-03, 1.5235e-02, 1.0576e-01, 2.7481e-01,
        6.0093e-01, 7.9828e-01, 9.3123e-01, 9.5791e-01, 9.7753e-01,
        9.8302e-01, 9.8727e-01, 9.9091e-01, 9.9163e-01, 9.9134e-01,
        9.8903e-01, 9.7732e-01, 9.6092e-01, 8.5311e-01, 6.9748e-01,
        4.4618e-01, 2.6524e-01, 1.1946e-01, 7.1549e-02, 3.3065e-02,
        1.3445e-02, 5.5437e-03, 3.5021e-03, 2.1437e-03, 1.1620e-03,
        9.3346e-04, 8.3968e-04, 8.1329e-04, 6.5914e-04, 6.6177e-04,
        9.7795e-04, 9.8678e-04, 8.4194e-04, 3.3677e-04, 0.0000e+00),
      T(0.0000e+00, 2.1760e-05, 5.4401e-05, 7.1501e-05, 7.8856e-05,
        6.6719e-05, 9.2789e-05, 1.3796e-04, 3.5185e-04, 8.3135e-04,
        1.8421e-03, 5.8234e-03, 1.1290e-02, 7.3462e-02, 1.9395e-01,
        4.3108e-01, 6.4041e-01, 8.3585e-01, 9.0036e-01, 9.4900e-01,
        9.6590e-01, 9.7680e-01, 9.8470e-01, 9.8694e-01, 9.8836e-01,
        9.8814e-01, 9.8299e-01, 9.7539e-01, 9.2820e-01, 8.5085e-01,
        7.1319e-01, 5.5136e-01, 3.7744e-01, 2.3440e-01, 1.1573e-01,
        4.5771e-02, 1.5526e-02, 5.1371e-03, 2.7968e-03, 1.1034e-03,
        7.0364e-04, 5.0126e-04, 3.9757e-04, 2.8806e-04, 2.6012e-04,
        3.9531e-04, 3.9530e-04, 3.2769e-04, 1.3107e-04, 0.0000e+00),
      T(0.0000e+00, 2.2431e-05, 5.6078e-05, 7.4358e-05, 8.3216e-05,
        7.3232e-05, 1.0648e-04, 1.6134e-04, 3.7136e-04, 8.1448e-04,
        1.7238e-03, 4.3298e-03, 7.7842e-03, 4.4596e-02, 1.1722e-01,
        2.6148e-01, 4.5995e-01, 6.8552e-01, 7.9053e-01, 8.7729e-01,
        9.2752e-01, 9.5524e-01, 9.7169e-01, 9.8032e-01, 9.8681e-01,
        9.8903e-01, 9.8814e-01, 9.8569e-01, 9.7258e-01, 9.4926e-01,
        9.0551e-01, 8.1203e-01, 6.9367e-01, 5.3742e-01, 3.8225e-01,
        2.2925e-01, 1.2249e-01, 3.8871e-02, 1.8852e-02, 4.6434e-03,
        2.0556e-03, 8.3333e-04, 2.9377e-04, 1.9638e-04, 1.4478e-04,
        1.8475e-04, 1.8635e-04, 1.6875e-04, 6.7502e-05, 0.0000e+00),
      T(0.0000e+00, 2.1468e-05, 5.3671e-05, 7.3507e-05, 8.3611e-05,
        7.4253e-05, 1.1157e-04, 1.7223e-04, 3.6291e-04, 7.1055e-04,
        1.3721e-03, 3.2127e-03, 5.6428e-03, 2.6406e-02, 6.7099e-02,
        1.4765e-01, 3.1155e-01, 5.1714e-01, 6.5450e-01, 7.7871e-01,
        8.7660e-01, 9.2840e-01, 9.5716e-01, 9.7452e-01, 9.8768e-01,
        9.9244e-01, 9.9493e-01, 9.9630e-01, 9.9658e-01, 9.9626e-01,
        9.9477e-01, 9.8822e-01, 9.7914e-01, 9.0114e-01, 7.7684e-01,
        5.5995e-01, 3.5445e-01, 1.5464e-01, 7.6868e-02, 2.0729e-02,
        7.8576e-03, 2.3477e-03, 5.1828e-04, 3.2766e-04, 1.8523e-04,
        1.3918e-04, 1.1605e-04, 1.0437e-04, 4.1747e-05, 0.0000e+00),
      T(0.0000e+00, 3.0897e-05, 7.7242e-05, 1.0373e-04, 1.1658e-04,
        1.0215e-04, 1.6525e-04, 2.6711e-04, 4.4954e-04, 8.2670e-04,
        1.5933e-03, 3.2154e-03, 5.2651e-03, 2.1791e-02, 5.4232e-02,
        1.1850e-01, 2.5927e-01, 4.3829e-01, 5.9635e-01, 7.4045e-01,
        8.5661e-01, 9.2346e-01, 9.6565e-01, 9.7911e-01, 9.8977e-01,
        9.9480e-01, 9.9695e-01, 9.9766e-01, 9.9820e-01, 9.9845e-01,
        9.9815e-01, 9.9664e-01, 9.9452e-01, 9.7981e-01, 9.5097e-01,
        8.9386e-01, 7.3283e-01, 5.1982e-01, 2.6752e-01, 8.1488e-02,
        2.7969e-02, 6.6078e-03, 1.3256e-03, 7.5215e-04, 3.3597e-04,
        2.3440e-04, 1.7958e-04, 1.4815e-04, 5.9260e-05, 0.0000e+00),
      T(0.0000e+00, 3.8091e-05, 9.5227e-05, 1.2842e-04, 1.4744e-04,
        1.3812e-04, 2.0408e-04, 3.0767e-04, 6.0083e-04, 1.0800e-03,
        1.9313e-03, 3.7529e-03, 6.0597e-03, 2.1947e-02, 5.2924e-02,
        1.1408e-01, 2.3261e-01, 3.7981e-01, 5.4971e-01, 7.0490e-01,
        8.3068e-01, 9.0226e-01, 9.4673e-01, 9.6779e-01, 9.8398e-01,
        9.9041e-01, 9.9423e-01, 9.9674e-01, 9.9772e-01, 9.9842e-01,
        9.9855e-01, 9.9823e-01, 9.9770e-01, 9.9560e-01, 9.8983e-01,
        9.7671e-01, 9.0715e-01, 8.0936e-01, 5.8823e-01, 3.6854e-01,
        1.5172e-01, 5.0679e-02, 7.5173e-03, 4.1375e-03, 1.6362e-03,
        8.9163e-04, 5.6545e-04, 4.4846e-04, 1.7938e-04, 0.0000e+00),
      T(0.0000e+00, 5.4788e-05, 1.3697e-04, 1.8301e-04, 2.0799e-04,
        1.9089e-04, 2.7187e-04, 4.0190e-04, 7.6129e-04, 1.3842e-03,
        2.5341e-03, 5.0345e-03, 8.2100e-03, 2.8757e-02, 6.4603e-02,
        1.3105e-01, 2.4648e-01, 3.8641e-01, 5.5999e-01, 7.1267e-01,
        8.2356e-01, 8.8757e-01, 9.2814e-01, 9.5446e-01, 9.7495e-01,
        9.8376e-01, 9.9001e-01, 9.9497e-01, 9.9685e-01, 9.9818e-01,
        9.9845e-01, 9.9843e-01, 9.9828e-01, 9.9758e-01, 9.9648e-01,
        9.9458e-01, 9.8154e-01, 9.6292e-01, 8.2946e-01, 6.3955e-01,
        3.3673e-01, 1.5180e-01, 2.5812e-02, 1.2929e-02, 3.7071e-03,
        1.8045e-03, 9.9961e-04, 7.4353e-04, 2.9741e-04, 0.0000e+00),
      T(0.0000e+00, 9.4743e-05, 2.3686e-04, 2.9807e-04, 3.2782e-04,
        2.9462e-04, 4.1576e-04, 6.1407e-04, 1.0586e-03, 1.9787e-03,
        3.8497e-03, 7.9081e-03, 1.3060e-02, 4.5579e-02, 9.3807e-02,
        1.7345e-01, 3.0403e-01, 4.6008e-01, 6.2473e-01, 7.6034e-01,
        8.3788e-01, 8.8436e-01, 9.1530e-01, 9.4290e-01, 9.6501e-01,
        9.7614e-01, 9.8514e-01, 9.9307e-01, 9.9606e-01, 9.9815e-01,
        9.9845e-01, 9.9858e-01, 9.9862e-01, 9.9825e-01, 9.9781e-01,
        9.9724e-01, 9.9450e-01, 9.9068e-01, 9.4664e-01, 8.2328e-01,
        5.4128e-01, 2.9069e-01, 5.5802e-02, 2.7052e-02, 6.6531e-03,
        2.9567e-03, 1.4364e-03, 1.0042e-03, 4.0167e-04, 0.0000e+00),
      T(0.0000e+00, 2.0123e-04, 5.0309e-04, 5.6050e-04, 5.9340e-04,
        5.7729e-04, 7.8051e-04, 1.0934e-03, 2.0592e-03, 3.9078e-03,
        7.5218e-03, 1.5557e-02, 2.5802e-02, 8.3967e-02, 1.5727e-01,
        2.6083e-01, 4.0291e-01, 5.6424e-01, 6.8873e-01, 7.9368e-01,
        8.5950e-01, 8.8973e-01, 9.0217e-01, 9.3426e-01, 9.5879e-01,
        9.6822e-01, 9.7980e-01, 9.9245e-01, 9.9558e-01, 9.9786e-01,
        9.9842e-01, 9.9860e-01, 9.9858e-01, 9.9853e-01, 9.9828e-01,
        9.9766e-01, 9.9594e-01, 9.9368e-01, 9.7093e-01, 8.7705e-01,
        6.4093e-01, 3.7299e-01, 8.9145e-02, 4.3757e-02, 1.1270e-02,
        4.5892e-03, 1.9674e-03, 1.3754e-03, 5.5014e-04, 0.0000e+00),
      T(0.0000e+00, 4.4289e-04, 1.1072e-03, 1.3850e-03, 1.5653e-03,
        1.5507e-03, 2.2823e-03, 3.3871e-03, 7.2079e-03, 1.3604e-02,
        2.5151e-02, 4.4963e-02, 6.8908e-02, 1.7293e-01, 2.8402e-01,
        4.0922e-01, 5.3822e-01, 6.6912e-01, 7.5877e-01, 8.3257e-01,
        8.7469e-01, 8.9524e-01, 9.0502e-01, 9.2916e-01, 9.5089e-01,
        9.6777e-01, 9.8087e-01, 9.9207e-01, 9.9549e-01, 9.9794e-01,
        9.9845e-01, 9.9865e-01, 9.9870e-01, 9.9870e-01, 9.9855e-01,
        9.9808e-01, 9.9697e-01, 9.9554e-01, 9.8253e-01, 9.2544e-01,
        7.8018e-01, 5.0970e-01, 1.7662e-01, 8.3528e-02, 1.7898e-02,
        7.1849e-03, 2.8908e-03, 1.8061e-03, 7.2245e-04, 0.0000e+00),
      T(0.0000e+00, 1.6306e-03, 4.0766e-03, 5.6184e-03, 6.9363e-03,
        7.8061e-03, 1.3040e-02, 2.0456e-02, 3.7795e-02, 6.3015e-02,
        1.0400e-01, 1.5140e-01, 2.0201e-01, 3.2255e-01, 4.4509e-01,
        5.7163e-01, 6.7177e-01, 7.5871e-01, 8.1616e-01, 8.6459e-01,
        8.9499e-01, 9.0898e-01, 9.1477e-01, 9.3701e-01, 9.5770e-01,
        9.7531e-01, 9.8620e-01, 9.9373e-01, 9.9628e-01, 9.9811e-01,
        9.9850e-01, 9.9869e-01, 9.9877e-01, 9.9879e-01, 9.9864e-01,
        9.9814e-01, 9.9737e-01, 9.9646e-01, 9.8929e-01, 9.6055e-01,
        8.8870e-01, 6.4995e-01, 3.2775e-01, 1.6182e-01, 4.2525e-02,
        1.6501e-02, 6.1959e-03, 3.7512e-03, 1.5005e-03, 0.0000e+00),
      T(0.0000e+00, 6.5821e-03, 1.6455e-02, 2.4646e-02, 3.2329e-02,
        3.8994e-02, 5.8704e-02, 8.4936e-02, 1.3516e-01, 1.9355e-01,
        2.6825e-01, 3.4261e-01, 4.1679e-01, 5.1029e-01, 6.0801e-01,
        7.1421e-01, 7.7708e-01, 8.1829e-01, 8.4936e-01, 8.8068e-01,
        9.1250e-01, 9.2386e-01, 9.2497e-01, 9.5308e-01, 9.7567e-01,
        9.8723e-01, 9.9338e-01, 9.9683e-01, 9.9765e-01, 9.9829e-01,
        9.9857e-01, 9.9871e-01, 9.9877e-01, 9.9879e-01, 9.9858e-01,
        9.9791e-01, 9.9728e-01, 9.9668e-01, 9.9320e-01, 9.8076e-01,
        9.5045e-01, 7.7742e-01, 5.3303e-01, 2.8083e-01, 9.3831e-02,
        3.7227e-02, 1.4218e-02, 8.0068e-03, 3.2027e-03, 0.0000e+00),
      T(0.0000e+00, 2.5757e-02, 6.4391e-02, 1.0116e-01, 1.3654e-01,
        1.6913e-01, 2.3376e-01, 3.1441e-01, 4.4339e-01, 5.3889e-01,
        5.6743e-01, 5.9432e-01, 6.2038e-01, 6.3593e-01, 6.7190e-01,
        7.4868e-01, 7.8653e-01, 8.0492e-01, 8.3088e-01, 8.5715e-01,
        8.8405e-01, 9.0338e-01, 9.1892e-01, 9.4918e-01, 9.7417e-01,
        9.8863e-01, 9.9491e-01, 9.9710e-01, 9.9791e-01, 9.9849e-01,
        9.9863e-01, 9.9871e-01, 9.9877e-01, 9.9874e-01, 9.9855e-01,
        9.9807e-01, 9.9755e-01, 9.9701e-01, 9.9448e-01, 9.8747e-01,
        9.7154e-01, 8.7769e-01, 7.4487e-01, 4.3390e-01, 1.9053e-01,
        8.2369e-02, 3.4310e-02, 1.6304e-02, 6.5215e-03, 0.0000e+00),
      T(0.0000e+00, 3.0875e-02, 7.7188e-02, 1.0889e-01, 1.4070e-01,
        1.7270e-01, 2.2856e-01, 2.9635e-01, 4.1450e-01, 4.9846e-01,
        5.1403e-01, 5.4743e-01, 5.8975e-01, 5.9267e-01, 6.0861e-01,
        6.5058e-01, 6.7334e-01, 6.8649e-01, 6.8381e-01, 7.0511e-01,
        7.7437e-01, 8.2962e-01, 8.7785e-01, 9.3138e-01, 9.7198e-01,
        9.8672e-01, 9.9350e-01, 9.9632e-01, 9.9718e-01, 9.9785e-01,
        9.9812e-01, 9.9836e-01, 9.9858e-01, 9.9856e-01, 9.9835e-01,
        9.9778e-01, 9.9730e-01, 9.9688e-01, 9.9472e-01, 9.9024e-01,
        9.8110e-01, 9.2580e-01, 8.4741e-01, 5.9254e-01, 3.7067e-01,
        2.1479e-01, 1.2356e-01, 6.4641e-02, 2.5856e-02, 0.0000e+00),
      T(0.0000e+00, 2.6255e-02, 6.5637e-02, 8.3259e-02, 1.0168e-01,
        1.2172e-01, 1.5510e-01, 1.9516e-01, 2.8370e-01, 3.4715e-01,
        3.6039e-01, 3.9565e-01, 4.4192e-01, 4.4949e-01, 4.6132e-01,
        4.8168e-01, 4.9330e-01, 5.0055e-01, 4.8602e-01, 5.0671e-01,
        5.9783e-01, 6.9594e-01, 7.9755e-01, 8.8920e-01, 9.5779e-01,
        9.8026e-01, 9.9051e-01, 9.9465e-01, 9.9608e-01, 9.9715e-01,
        9.9751e-01, 9.9791e-01, 9.9834e-01, 9.9830e-01, 9.9809e-01,
        9.9752e-01, 9.9707e-01, 9.9669e-01, 9.9476e-01, 9.9139e-01,
        9.8515e-01, 9.5000e-01, 9.0041e-01, 7.1811e-01, 5.4534e-01,
        3.9163e-01, 2.6682e-01, 1.5644e-01, 6.2577e-02, 0.0000e+00),
      T(0.0000e+00, 1.6704e-02, 4.1760e-02, 4.6332e-02, 5.1987e-02,
        5.9810e-02, 7.6875e-02, 9.8561e-02, 1.5948e-01, 2.0384e-01,
        2.1508e-01, 2.3004e-01, 2.4686e-01, 2.5906e-01, 2.7336e-01,
        2.9185e-01, 2.9723e-01, 2.9606e-01, 2.8262e-01, 2.9989e-01,
        3.7856e-01, 5.0498e-01, 6.5527e-01, 7.9357e-01, 9.0167e-01,
        9.4940e-01, 9.7301e-01, 9.8458e-01, 9.8879e-01, 9.9222e-01,
        9.9411e-01, 9.9586e-01, 9.9756e-01, 9.9759e-01, 9.9750e-01,
        9.9719e-01, 9.9678e-01, 9.9634e-01, 9.9430e-01, 9.9071e-01,
        9.8399e-01, 9.5624e-01, 9.1799e-01, 7.9107e-01, 6.6963e-01,
        5.5913e-01, 4.2164e-01, 2.7067e-01, 1.0827e-01, 0.0000e+00),
      T(0.0000e+00, 1.7143e-02, 4.2858e-02, 5.0972e-02, 6.4668e-02,
        8.9527e-02, 1.3595e-01, 1.9315e-01, 2.4054e-01, 2.6911e-01,
        2.6005e-01, 2.2115e-01, 1.6732e-01, 1.6299e-01, 1.7475e-01,
        2.1870e-01, 2.3251e-01, 2.3126e-01, 1.7617e-01, 1.5427e-01,
        1.9875e-01, 2.7385e-01, 3.6428e-01, 5.3869e-01, 6.9519e-01,
        8.1585e-01, 8.8798e-01, 9.3586e-01, 9.5157e-01, 9.6570e-01,
        9.7667e-01, 9.8586e-01, 9.9416e-01, 9.9488e-01, 9.9548e-01,
        9.9588e-01, 9.9561e-01, 9.9500e-01, 9.9131e-01, 9.8485e-01,
        9.7283e-01, 9.4006e-01, 8.9690e-01, 7.7189e-01, 6.5269e-01,
        5.4508e-01, 4.3344e-01, 3.1978e-01, 1.2791e-01, 0.0000e+00),
      T(0.0000e+00, 1.8748e-02, 4.6870e-02, 6.1607e-02, 8.2744e-02,
        1.1668e-01, 1.8790e-01, 2.7777e-01, 2.9548e-01, 3.0247e-01,
        2.8802e-01, 2.2402e-01, 1.3524e-01, 1.2777e-01, 1.3933e-01,
        1.8896e-01, 2.0891e-01, 2.1402e-01, 1.4941e-01, 1.1704e-01,
        1.4916e-01, 1.9439e-01, 2.4618e-01, 3.6095e-01, 4.6674e-01,
        5.5458e-01, 6.5141e-01, 7.5273e-01, 8.0684e-01, 8.6120e-01,
        9.1607e-01, 9.5556e-01, 9.8736e-01, 9.9038e-01, 9.9301e-01,
        9.9485e-01, 9.9503e-01, 9.9437e-01, 9.8782e-01, 9.7448e-01,
        9.4753e-01, 8.7173e-01, 7.7150e-01, 5.9215e-01, 4.4443e-01,
        3.5997e-01, 2.8547e-01, 2.1596e-01, 8.6385e-02, 0.0000e+00),
      T(0.0000e+00, 2.3143e-02, 5.7858e-02, 7.7477e-02, 1.0262e-01,
        1.3880e-01, 2.1537e-01, 3.1212e-01, 2.9273e-01, 2.7477e-01,
        2.5970e-01, 1.9903e-01, 1.1557e-01, 1.1149e-01, 1.2721e-01,
        1.8252e-01, 2.0614e-01, 2.1392e-01, 1.4467e-01, 1.0908e-01,
        1.4078e-01, 1.7958e-01, 2.2193e-01, 2.7239e-01, 3.2113e-01,
        3.6646e-01, 4.5060e-01, 5.5415e-01, 6.2703e-01, 7.1120e-01,
        8.1795e-01, 8.9937e-01, 9.6811e-01, 9.7914e-01, 9.8792e-01,
        9.9222e-01, 9.9316e-01, 9.9241e-01, 9.8223e-01, 9.5671e-01,
        9.0054e-01, 7.6534e-01, 5.9063e-01, 4.0303e-01, 2.5921e-01,
        2.0295e-01, 1.6092e-01, 1.2599e-01, 5.0397e-02, 0.0000e+00),
      T(0.0000e+00, 2.9514e-02, 7.3785e-02, 9.7793e-02, 1.2452e-01,
        1.5666e-01, 2.2109e-01, 3.0165e-01, 2.4655e-01, 2.0512e-01,
        1.9105e-01, 1.5198e-01, 1.0042e-01, 1.0280e-01, 1.2525e-01,
        1.8785e-01, 2.1338e-01, 2.2037e-01, 1.4533e-01, 1.0803e-01,
        1.4625e-01, 1.9489e-01, 2.4874e-01, 2.5740e-01, 2.6990e-01,
        2.9009e-01, 3.3326e-01, 3.8792e-01, 4.5297e-01, 5.4689e-01,
        6.9854e-01, 8.2272e-01, 9.3317e-01, 9.5946e-01, 9.7974e-01,
        9.8800e-01, 9.9019e-01, 9.8936e-01, 9.7444e-01, 9.3247e-01,
        8.3641e-01, 6.4124e-01, 3.9651e-01, 2.5462e-01, 1.5003e-01,
        1.2002e-01, 1.0015e-01, 8.5342e-02, 3.4137e-02, 0.0000e+00),
      T(0.0000e+00, 3.2974e-02, 8.2436e-02, 1.2017e-01, 1.5293e-01,
        1.7576e-01, 2.3337e-01, 3.0838e-01, 2.4560e-01, 1.9912e-01,
        1.8525e-01, 1.4566e-01, 9.3204e-02, 9.8058e-02, 1.2071e-01,
        1.7894e-01, 2.0760e-01, 2.2148e-01, 1.4249e-01, 1.0367e-01,
        1.4519e-01, 1.8924e-01, 2.3456e-01, 2.4151e-01, 2.5436e-01,
        2.7899e-01, 3.0284e-01, 3.2630e-01, 3.7557e-01, 4.6058e-01,
        6.1708e-01, 7.5298e-01, 8.7857e-01, 9.2957e-01, 9.6871e-01,
        9.8413e-01, 9.8885e-01, 9.8821e-01, 9.6577e-01, 9.0832e-01,
        7.8085e-01, 5.6670e-01, 3.0920e-01, 1.9602e-01, 1.1441e-01,
        9.5951e-02, 8.1534e-02, 6.9138e-02, 2.7655e-02, 0.0000e+00),
      T(0.0000e+00, 4.0984e-02, 1.0246e-01, 1.4688e-01, 1.7983e-01,
        1.8983e-01, 2.2702e-01, 2.7782e-01, 2.4506e-01, 2.1605e-01,
        1.9450e-01, 1.4877e-01, 9.0955e-02, 9.0818e-02, 1.1008e-01,
        1.6815e-01, 1.8783e-01, 1.8832e-01, 1.2098e-01, 8.9212e-02,
        1.2857e-01, 1.8540e-01, 2.5096e-01, 2.7652e-01, 2.9589e-01,
        3.0285e-01, 3.2308e-01, 3.4993e-01, 3.5234e-01, 4.0630e-01,
        5.6333e-01, 7.0907e-01, 8.4917e-01, 9.1519e-01, 9.6477e-01,
        9.8148e-01, 9.8716e-01, 9.8732e-01, 9.6447e-01, 9.0367e-01,
        7.6697e-01, 5.5284e-01, 2.9998e-01, 1.9721e-01, 1.1892e-01,
        8.9606e-02, 7.3191e-02, 6.3226e-02, 2.5290e-02, 0.0000e+00),
      T(0.0000e+00, 4.5622e-02, 1.1406e-01, 1.6477e-01, 1.9823e-01,
        1.9716e-01, 2.1624e-01, 2.4539e-01, 2.3829e-01, 2.2452e-01,
        1.9739e-01, 1.5122e-01, 9.5534e-02, 9.3674e-02, 1.1025e-01,
        1.6369e-01, 1.7970e-01, 1.7698e-01, 1.1008e-01, 7.8204e-02,
        1.1635e-01, 1.7230e-01, 2.3716e-01, 2.8639e-01, 3.1825e-01,
        3.1539e-01, 3.3262e-01, 3.5990e-01, 3.4228e-01, 3.7795e-01,
        5.2022e-01, 6.6172e-01, 8.0283e-01, 8.8885e-01, 9.5377e-01,
        9.7649e-01, 9.8466e-01, 9.8558e-01, 9.6125e-01, 8.9934e-01,
        7.6225e-01, 5.4868e-01, 2.9687e-01, 2.0154e-01, 1.2567e-01,
        8.8746e-02, 6.9590e-02, 5.9320e-02, 2.3728e-02, 0.0000e+00),
      T(0.0000e+00, 4.3822e-02, 1.0956e-01, 1.6298e-01, 1.9712e-01,
        1.9270e-01, 2.0143e-01, 2.1675e-01, 2.2194e-01, 2.1622e-01,
        1.8869e-01, 1.4831e-01, 1.0151e-01, 1.0223e-01, 1.1770e-01,
        1.6267e-01, 1.8107e-01, 1.8619e-01, 1.1104e-01, 7.3279e-02,
        1.1032e-01, 1.4982e-01, 1.9056e-01, 2.5840e-01, 3.0450e-01,
        3.0710e-01, 3.2220e-01, 3.4355e-01, 3.3611e-01, 3.7147e-01,
        4.9242e-01, 6.1993e-01, 7.5071e-01, 8.5781e-01, 9.3944e-01,
        9.7012e-01, 9.8149e-01, 9.8320e-01, 9.5723e-01, 8.9844e-01,
        7.7401e-01, 5.6250e-01, 3.0744e-01, 2.1100e-01, 1.3345e-01,
        9.3651e-02, 7.1473e-02, 5.8105e-02, 2.3242e-02, 0.0000e+00),
      T(0.0000e+00, 3.1243e-02, 7.8108e-02, 1.1127e-01, 1.3951e-01,
        1.5790e-01, 1.7003e-01, 1.7905e-01, 1.8929e-01, 1.8929e-01,
        1.6881e-01, 1.3131e-01, 8.5303e-02, 8.6304e-02, 1.0153e-01,
        1.4521e-01, 1.5781e-01, 1.5488e-01, 9.9546e-02, 7.1404e-02,
        9.7642e-02, 1.2846e-01, 1.6156e-01, 2.1783e-01, 2.6309e-01,
        2.8632e-01, 3.1610e-01, 3.4916e-01, 3.3783e-01, 3.7663e-01,
        5.1568e-01, 6.4902e-01, 7.7951e-01, 8.7851e-01, 9.5083e-01,
        9.6977e-01, 9.7856e-01, 9.8226e-01, 9.6618e-01, 9.3261e-01,
        8.6409e-01, 6.7830e-01, 4.3388e-01, 2.9020e-01, 1.7523e-01,
        1.1768e-01, 8.7340e-02, 7.0604e-02, 2.8242e-02, 0.0000e+00),
      T(0.0000e+00, 2.3291e-02, 5.8227e-02, 7.9606e-02, 9.6198e-02,
        1.0321e-01, 1.0987e-01, 1.1636e-01, 1.2595e-01, 1.2919e-01,
        1.1971e-01, 9.8355e-02, 7.1070e-02, 7.4620e-02, 8.8585e-02,
        1.2338e-01, 1.4013e-01, 1.4785e-01, 9.3880e-02, 6.6927e-02,
        9.4014e-02, 1.1960e-01, 1.4443e-01, 2.0282e-01, 2.4800e-01,
        2.6675e-01, 2.9908e-01, 3.3820e-01, 3.3851e-01, 3.8310e-01,
        5.1624e-01, 6.4953e-01, 7.8289e-01, 8.7916e-01, 9.4964e-01,
        9.6854e-01, 9.7748e-01, 9.8145e-01, 9.6697e-01, 9.3979e-01,
        8.8720e-01, 7.2646e-01, 5.1164e-01, 3.4970e-01, 2.1534e-01,
        1.3613e-01, 9.4821e-02, 7.2471e-02, 2.8988e-02, 0.0000e+00),
      T(0.0000e+00, 1.5334e-02, 3.8335e-02, 4.9284e-02, 5.5756e-02,
        5.3272e-02, 5.5068e-02, 5.9006e-02, 6.5186e-02, 6.8420e-02,
        6.5761e-02, 5.7346e-02, 4.6053e-02, 4.9515e-02, 5.8958e-02,
        8.0362e-02, 9.6087e-02, 1.0897e-01, 7.6166e-02, 6.4733e-02,
        9.6048e-02, 1.2400e-01, 1.5027e-01, 2.0995e-01, 2.5364e-01,
        2.6534e-01, 2.9834e-01, 3.4199e-01, 3.4481e-01, 3.9326e-01,
        5.3297e-01, 6.6170e-01, 7.8494e-01, 8.8028e-01, 9.4903e-01,
        9.6462e-01, 9.7311e-01, 9.7803e-01, 9.6540e-01, 9.4443e-01,
        9.0680e-01, 7.8129e-01, 6.1184e-01, 4.3011e-01, 2.7379e-01,
        1.6827e-01, 1.1143e-01, 7.8918e-02, 3.1567e-02, 0.0000e+00),
      T(0.0000e+00, 7.4892e-03, 1.8723e-02, 2.0474e-02, 2.0631e-02,
        1.7601e-02, 1.7335e-02, 1.8451e-02, 2.0263e-02, 2.1166e-02,
        2.0252e-02, 1.7871e-02, 1.4756e-02, 1.5514e-02, 1.8393e-02,
        2.5516e-02, 3.3807e-02, 4.2681e-02, 4.7819e-02, 6.3016e-02,
        9.8330e-02, 1.3383e-01, 1.6943e-01, 2.2894e-01, 2.7039e-01,
        2.7571e-01, 3.0927e-01, 3.5695e-01, 3.5413e-01, 4.0465e-01,
        5.6184e-01, 6.8552e-01, 7.9245e-01, 8.8613e-01, 9.5121e-01,
        9.5910e-01, 9.6624e-01, 9.7300e-01, 9.6334e-01, 9.5064e-01,
        9.3184e-01, 8.4706e-01, 7.2930e-01, 5.2919e-01, 3.5067e-01,
        2.1529e-01, 1.3856e-01, 9.1153e-02, 3.6461e-02, 0.0000e+00),
      T(0.0000e+00, 4.8481e-03, 1.2120e-02, 1.2534e-02, 1.2030e-02,
        9.6912e-03, 9.4234e-03, 1.0191e-02, 1.1044e-02, 1.1683e-02,
        1.1894e-02, 1.0362e-02, 7.9573e-03, 8.3855e-03, 9.7760e-03,
        1.3091e-02, 1.7671e-02, 2.2883e-02, 3.2364e-02, 4.9662e-02,
        8.2594e-02, 1.1703e-01, 1.5221e-01, 2.2210e-01, 2.6538e-01,
        2.5543e-01, 2.8624e-01, 3.3745e-01, 3.4941e-01, 4.0501e-01,
        5.4785e-01, 6.8073e-01, 8.0863e-01, 8.9333e-01, 9.5187e-01,
        9.5813e-01, 9.6531e-01, 9.7296e-01, 9.6258e-01, 9.5040e-01,
        9.3466e-01, 8.6654e-01, 7.7222e-01, 5.9741e-01, 4.2629e-01,
        2.6257e-01, 1.6432e-01, 9.8795e-02, 3.9518e-02, 0.0000e+00),
      T(0.0000e+00, 3.2285e-03, 8.0713e-03, 7.9556e-03, 7.2625e-03,
        5.4145e-03, 4.9765e-03, 5.2435e-03, 6.1985e-03, 6.8199e-03,
        6.7739e-03, 6.4307e-03, 5.9388e-03, 5.9224e-03, 7.0359e-03,
        1.0409e-02, 1.4031e-02, 1.7777e-02, 2.9553e-02, 4.6564e-02,
        7.4045e-02, 1.0130e-01, 1.2844e-01, 1.7866e-01, 2.1393e-01,
        2.1927e-01, 2.5864e-01, 3.1503e-01, 3.4326e-01, 4.1234e-01,
        5.6310e-01, 6.9443e-01, 8.1604e-01, 8.9810e-01, 9.5331e-01,
        9.5480e-01, 9.6126e-01, 9.7020e-01, 9.5896e-01, 9.4750e-01,
        9.3559e-01, 8.8753e-01, 8.2140e-01, 6.8228e-01, 5.2439e-01,
        3.2898e-01, 2.0494e-01, 1.1659e-01, 4.6637e-02, 0.0000e+00),
      T(0.0000e+00, 2.5654e-03, 6.4135e-03, 6.2062e-03, 5.4430e-03,
        3.5680e-03, 2.9841e-03, 3.0457e-03, 3.8523e-03, 4.3677e-03,
        4.3006e-03, 4.4909e-03, 4.8100e-03, 4.8111e-03, 5.7490e-03,
        8.5607e-03, 1.1716e-02, 1.5043e-02, 2.5800e-02, 4.0676e-02,
        6.3792e-02, 8.4323e-02, 1.0356e-01, 1.4223e-01, 1.7259e-01,
        1.8632e-01, 2.2865e-01, 2.8528e-01, 3.2619e-01, 4.0118e-01,
        5.4434e-01, 6.7832e-01, 8.0772e-01, 8.9173e-01, 9.4740e-01,
        9.4640e-01, 9.5361e-01, 9.6493e-01, 9.5213e-01, 9.4010e-01,
        9.2960e-01, 8.9190e-01, 8.4061e-01, 7.3270e-01, 5.9343e-01,
        3.9146e-01, 2.4952e-01, 1.3760e-01, 5.5041e-02, 0.0000e+00),
      T(0.0000e+00, 2.7776e-03, 6.9440e-03, 6.7437e-03, 5.8149e-03,
        3.4293e-03, 2.7060e-03, 2.8137e-03, 3.0493e-03, 3.3013e-03,
        3.5858e-03, 3.6133e-03, 3.5122e-03, 3.8683e-03, 4.4780e-03,
        5.5947e-03, 8.1167e-03, 1.1341e-02, 1.8543e-02, 3.0087e-02,
        5.0315e-02, 6.5920e-02, 7.9212e-02, 1.1876e-01, 1.4804e-01,
        1.5680e-01, 1.9185e-01, 2.4003e-01, 2.9753e-01, 3.7289e-01,
        4.8399e-01, 6.2297e-01, 7.7588e-01, 8.6631e-01, 9.2720e-01,
        9.2901e-01, 9.3938e-01, 9.5403e-01, 9.3906e-01, 9.2536e-01,
        9.1422e-01, 8.7700e-01, 8.2675e-01, 7.4306e-01, 6.2674e-01,
        4.4514e-01, 2.9681e-01, 1.6511e-01, 6.6046e-02, 0.0000e+00),
      T(0.0000e+00, 3.6061e-03, 9.0151e-03, 7.9336e-03, 6.2377e-03,
        3.3131e-03, 2.1923e-03, 1.9735e-03, 1.8405e-03, 1.7306e-03,
        1.6668e-03, 1.6675e-03, 1.7004e-03, 1.6748e-03, 1.8974e-03,
        2.6162e-03, 3.9657e-03, 5.6305e-03, 1.1128e-02, 2.0203e-02,
        3.6430e-02, 4.7712e-02, 5.6522e-02, 8.8533e-02, 1.1054e-01,
        1.1256e-01, 1.2836e-01, 1.5106e-01, 2.6408e-01, 3.5831e-01,
        4.1497e-01, 5.3884e-01, 6.9632e-01, 7.9904e-01, 8.7306e-01,
        8.8971e-01, 9.0715e-01, 9.2498e-01, 9.0809e-01, 8.9378e-01,
        8.8465e-01, 8.5042e-01, 8.0365e-01, 7.4199e-01, 6.4905e-01,
        4.9355e-01, 3.5272e-01, 2.1921e-01, 8.7683e-02, 0.0000e+00),
      T(0.0000e+00, 3.3314e-03, 8.3284e-03, 7.1207e-03, 5.3804e-03,
        2.5749e-03, 1.5147e-03, 1.3272e-03, 1.0936e-03, 9.1981e-04,
        8.6574e-04, 8.5662e-04, 8.6996e-04, 8.5916e-04, 1.0008e-03,
        1.4473e-03, 2.3075e-03, 3.3746e-03, 7.9505e-03, 1.5339e-02,
        2.8353e-02, 3.9975e-02, 5.0901e-02, 8.2517e-02, 1.0348e-01,
        1.0315e-01, 1.1696e-01, 1.3783e-01, 2.3885e-01, 3.2172e-01,
        3.6826e-01, 4.6231e-01, 5.8012e-01, 6.8432e-01, 7.6104e-01,
        7.8282e-01, 8.0598e-01, 8.2982e-01, 8.1701e-01, 8.0116e-01,
        7.7922e-01, 7.4308e-01, 6.9985e-01, 6.4089e-01, 5.6191e-01,
        4.4289e-01, 3.2862e-01, 2.1672e-01, 8.6689e-02, 0.0000e+00),
      T(0.0000e+00, 1.9273e-03, 4.8183e-03, 4.0713e-03, 3.0149e-03,
        1.3398e-03, 7.2467e-04, 6.3961e-04, 4.7892e-04, 3.6899e-04,
        3.6062e-04, 3.5292e-04, 3.4556e-04, 3.6821e-04, 4.5058e-04,
        6.5238e-04, 1.0798e-03, 1.6201e-03, 4.2407e-03, 8.3808e-03,
        1.5560e-02, 2.3221e-02, 3.1123e-02, 5.1207e-02, 6.4374e-02,
        6.3710e-02, 7.2789e-02, 8.6739e-02, 1.4191e-01, 1.8826e-01,
        2.1696e-01, 2.6551e-01, 3.2398e-01, 3.8888e-01, 4.3702e-01,
        4.5163e-01, 4.6781e-01, 4.8477e-01, 4.7842e-01, 4.6797e-01,
        4.4933e-01, 4.2584e-01, 3.9992e-01, 3.6271e-01, 3.1712e-01,
        2.5478e-01, 1.9286e-01, 1.3114e-01, 5.2456e-02, 0.0000e+00),
      T(0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
        0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00))))

    output.almostEqual(expectedOut, 1e-4) should be(true)
  }

  "bilinear with binary mask" should "be ok" in {
    val input = Tensor[Float](T(T(
      T(1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f),
      T(0.0, 1.0, 1.0, 1.0, 1.0, 0.0),
      T(1.0, 1.0, 1.0, 0.0, 0, 0.0),
      T(0.0, 0.0, 0.0, 0.0, 0.0, 1.0))))

    val output = Tensor[Float](1, 5, 8)
    Utils.bilinear(input, output)

    val expectedOut = Tensor[Float](T(T(T(
      T(1.0000, 0.3750, 0.3750, 1.0000, 1.0000, 0.3750, 0.3750, 1.0000),
      T(0.3000, 0.5500, 0.8125, 1.0000, 1.0000, 0.8125, 0.5500, 0.30000),
      T(0.5000, 0.8125, 1.0000, 0.9375, 0.5625, 0.5000, 0.3125, 0.0000),
      T(0.7000, 0.7000, 0.7000, 0.6125, 0.0875, 0.0000, 0.1125, 0.3000),
      T(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3750, 1.0000)))))

    output.almostEqual(expectedOut, 1e-6) should be(true)
  }

  "binary to rle" should "be ok" in {
    val mask = Tensor[Float](T(T(1, 0, 1, 1, 1), T(1, 0, 1, 1, 0)))
    val out = MaskUtils.binaryToRLE(mask)
    val expectedOut = Array(0, 2, 2, 5, 1)
    out.counts should be(expectedOut)
  }

  "decodeMaskInImage" should "be ok" in {
    val mask = Tensor[Float](T(T(
      T(1.7928e-04, 2.0692e-04, 1.1419e-04, 2.0437e-04, 4.1835e-04, 9.4657e-04,
        4.6943e-03, 1.4078e-02, 6.6533e-02, 2.0986e-01, 4.7807e-01, 6.9845e-01,
        8.3367e-01, 8.1354e-01, 6.1018e-01, 2.9873e-01, 1.1466e-01, 4.9374e-02,
        1.5091e-02, 5.1253e-03, 1.1708e-03, 5.3059e-04, 2.9873e-04, 1.7227e-04,
        1.4657e-04, 1.1615e-04, 2.4343e-04, 3.3061e-04),
      T(2.0778e-04, 2.3388e-04, 1.9466e-04, 3.5014e-04, 7.1720e-04, 1.6670e-03,
        8.4499e-03, 3.2401e-02, 1.6663e-01, 5.3996e-01, 7.9149e-01, 8.9112e-01,
        9.3543e-01, 9.3029e-01, 8.4267e-01, 5.8298e-01, 2.7246e-01, 1.0355e-01,
        3.4595e-02, 1.0017e-02, 1.7930e-03, 7.9974e-04, 3.4362e-04, 2.0355e-04,
        1.6328e-04, 1.1402e-04, 2.4033e-04, 2.7334e-04),
      T(9.5185e-05, 1.5875e-04, 2.2014e-04, 4.5034e-04, 1.5089e-03, 3.8962e-03,
        1.8745e-02, 8.5752e-02, 3.6358e-01, 7.8782e-01, 9.3798e-01, 9.6312e-01,
        9.7033e-01, 9.6447e-01, 9.3477e-01, 7.9702e-01, 4.8619e-01, 2.3604e-01,
        8.9071e-02, 2.2121e-02, 3.9173e-03, 1.1309e-03, 4.0723e-04, 1.8781e-04,
        8.3546e-05, 5.9426e-05, 6.1382e-05, 5.9903e-05),
      T(1.6401e-04, 2.6043e-04, 4.4878e-04, 9.2276e-04, 2.7423e-03, 8.2678e-03,
        4.0664e-02, 2.0156e-01, 6.4597e-01, 9.0380e-01, 9.6477e-01, 9.7386e-01,
        9.7921e-01, 9.7543e-01, 9.5784e-01, 9.0109e-01, 6.9198e-01, 4.5481e-01,
        2.1539e-01, 5.2143e-02, 7.8477e-03, 2.3775e-03, 5.2359e-04, 2.7515e-04,
        1.0030e-04, 6.8600e-05, 7.8394e-05, 6.1336e-05),
      T(1.3665e-04, 2.7183e-04, 6.3078e-04, 1.3654e-03, 4.5380e-03, 1.4096e-02,
        8.9603e-02, 3.7293e-01, 7.9767e-01, 9.4614e-01, 9.7820e-01, 9.8513e-01,
        9.9180e-01, 9.9073e-01, 9.8490e-01, 9.6567e-01, 8.7173e-01, 6.4768e-01,
        3.2502e-01, 6.8274e-02, 1.2379e-02, 2.3228e-03, 6.0599e-04, 2.2455e-04,
        7.6128e-05, 4.5087e-05, 2.9849e-05, 2.4246e-05),
      T(2.9395e-04, 5.2626e-04, 1.3691e-03, 3.0833e-03, 8.4784e-03, 2.4840e-02,
        1.0825e-01, 3.3781e-01, 7.2135e-01, 9.0736e-01, 9.7591e-01, 9.8762e-01,
        9.9407e-01, 9.9431e-01, 9.9110e-01, 9.8120e-01, 9.1879e-01, 7.4382e-01,
        3.6428e-01, 9.0287e-02, 1.5536e-02, 3.7618e-03, 7.5778e-04, 3.3695e-04,
        8.8488e-05, 5.0563e-05, 3.6956e-05, 2.5858e-05),
      T(3.3709e-04, 7.3902e-04, 2.1546e-03, 5.1880e-03, 1.4869e-02, 3.6619e-02,
        1.1205e-01, 2.4008e-01, 4.7358e-01, 7.7270e-01, 9.4354e-01, 9.8724e-01,
        9.9541e-01, 9.9609e-01, 9.9417e-01, 9.8742e-01, 9.4030e-01, 7.3967e-01,
        3.2890e-01, 6.3649e-02, 1.0635e-02, 2.0180e-03, 6.2573e-04, 1.9897e-04,
        7.7560e-05, 3.7549e-05, 2.0955e-05, 1.5558e-05),
      T(5.8491e-04, 1.1162e-03, 4.2690e-03, 1.3020e-02, 3.5157e-02, 8.7344e-02,
        1.5394e-01, 2.6169e-01, 3.9548e-01, 6.9451e-01, 9.2202e-01, 9.8254e-01,
        9.9533e-01, 9.9627e-01, 9.9226e-01, 9.7961e-01, 8.8020e-01, 5.1072e-01,
        1.6972e-01, 4.4443e-02, 8.6884e-03, 2.3970e-03, 7.7104e-04, 3.0885e-04,
        9.4350e-05, 4.3260e-05, 2.8203e-05, 1.8742e-05),
      T(1.2834e-03, 3.1489e-03, 1.4341e-02, 5.5467e-02, 1.6788e-01, 3.4051e-01,
        5.4373e-01, 7.1655e-01, 8.4651e-01, 9.4097e-01, 9.8247e-01, 9.9247e-01,
        9.9560e-01, 9.9519e-01, 9.8764e-01, 9.4701e-01, 7.2466e-01, 3.1205e-01,
        1.0391e-01, 3.3326e-02, 7.6892e-03, 2.1175e-03, 9.4444e-04, 3.1132e-04,
        9.5933e-05, 4.4204e-05, 2.4406e-05, 1.7895e-05),
      T(2.8443e-03, 8.0350e-03, 5.2463e-02, 2.4951e-01, 6.5350e-01, 8.9142e-01,
        9.6346e-01, 9.7836e-01, 9.8918e-01, 9.9353e-01, 9.9634e-01, 9.9751e-01,
        9.9703e-01, 9.9593e-01, 9.8269e-01, 9.3080e-01, 7.0195e-01, 3.2495e-01,
        1.5233e-01, 4.9156e-02, 1.3870e-02, 4.1192e-03, 1.5574e-03, 6.2875e-04,
        1.7067e-04, 7.4994e-05, 4.6740e-05, 2.8302e-05),
      T(7.8200e-03, 2.9424e-02, 1.6984e-01, 5.7369e-01, 9.2385e-01, 9.8158e-01,
        9.9368e-01, 9.9577e-01, 9.9798e-01, 9.9834e-01, 9.9887e-01, 9.9874e-01,
        9.9875e-01, 9.9813e-01, 9.9522e-01, 9.8773e-01, 9.0437e-01, 6.1899e-01,
        3.1323e-01, 1.2139e-01, 2.5527e-02, 7.0457e-03, 2.4347e-03, 8.0314e-04,
        2.1590e-04, 9.6527e-05, 5.6101e-05, 3.5453e-05),
      T(1.4658e-02, 6.5434e-02, 3.6357e-01, 8.3279e-01, 9.7732e-01, 9.9152e-01,
        9.9686e-01, 9.9773e-01, 9.9875e-01, 9.9897e-01, 9.9910e-01, 9.9905e-01,
        9.9904e-01, 9.9878e-01, 9.9812e-01, 9.9676e-01, 9.8603e-01, 9.4868e-01,
        7.3707e-01, 3.3155e-01, 7.9630e-02, 1.7003e-02, 4.4124e-03, 1.4714e-03,
        3.4973e-04, 1.4844e-04, 9.3148e-05, 5.0959e-05),
      T(2.6411e-02, 1.2346e-01, 5.0025e-01, 9.0578e-01, 9.9005e-01, 9.9616e-01,
        9.9839e-01, 9.9872e-01, 9.9927e-01, 9.9929e-01, 9.9939e-01, 9.9931e-01,
        9.9930e-01, 9.9917e-01, 9.9902e-01, 9.9880e-01, 9.9740e-01, 9.9226e-01,
        9.3064e-01, 5.7227e-01, 1.4149e-01, 3.4371e-02, 7.0848e-03, 2.0274e-03,
        4.6336e-04, 2.1692e-04, 1.1053e-04, 7.0626e-05),
      T(4.3833e-02, 2.0485e-01, 6.3357e-01, 9.4217e-01, 9.9302e-01, 9.9702e-01,
        9.9851e-01, 9.9892e-01, 9.9927e-01, 9.9931e-01, 9.9935e-01, 9.9928e-01,
        9.9929e-01, 9.9921e-01, 9.9915e-01, 9.9911e-01, 9.9859e-01, 9.9653e-01,
        9.6976e-01, 7.7589e-01, 2.4619e-01, 6.2726e-02, 1.4346e-02, 3.7506e-03,
        9.5355e-04, 3.7222e-04, 2.1213e-04, 1.1961e-04),
      T(6.9732e-02, 2.6408e-01, 7.5521e-01, 9.6384e-01, 9.9468e-01, 9.9765e-01,
        9.9899e-01, 9.9923e-01, 9.9955e-01, 9.9958e-01, 9.9955e-01, 9.9954e-01,
        9.9944e-01, 9.9939e-01, 9.9931e-01, 9.9922e-01, 9.9892e-01, 9.9771e-01,
        9.8597e-01, 8.6076e-01, 4.2889e-01, 1.3940e-01, 3.2867e-02, 1.1953e-02,
        3.6591e-03, 1.7576e-03, 6.4271e-04, 4.0583e-04),
      T(1.0522e-01, 3.7747e-01, 8.0611e-01, 9.6327e-01, 9.9445e-01, 9.9744e-01,
        9.9886e-01, 9.9920e-01, 9.9949e-01, 9.9951e-01, 9.9947e-01, 9.9942e-01,
        9.9928e-01, 9.9925e-01, 9.9912e-01, 9.9912e-01, 9.9890e-01, 9.9805e-01,
        9.9045e-01, 9.3178e-01, 6.2792e-01, 2.5893e-01, 1.0537e-01, 3.8054e-02,
        1.5579e-02, 6.1348e-03, 2.5883e-03, 1.2838e-03),
      T(1.5055e-01, 4.2908e-01, 8.5477e-01, 9.6827e-01, 9.9417e-01, 9.9711e-01,
        9.9880e-01, 9.9909e-01, 9.9950e-01, 9.9950e-01, 9.9939e-01, 9.9935e-01,
        9.9924e-01, 9.9920e-01, 9.9911e-01, 9.9900e-01, 9.9880e-01, 9.9757e-01,
        9.9317e-01, 9.6565e-01, 7.8117e-01, 4.1305e-01, 1.8546e-01, 9.3902e-02,
        3.8758e-02, 2.3142e-02, 1.3436e-02, 7.6208e-03),
      T(1.7158e-01, 4.6332e-01, 8.3340e-01, 9.5613e-01, 9.9301e-01, 9.9674e-01,
        9.9853e-01, 9.9894e-01, 9.9936e-01, 9.9933e-01, 9.9914e-01, 9.9911e-01,
        9.9889e-01, 9.9893e-01, 9.9850e-01, 9.9854e-01, 9.9785e-01, 9.9648e-01,
        9.9272e-01, 9.7598e-01, 8.8509e-01, 6.5937e-01, 4.1227e-01, 2.2791e-01,
        1.0047e-01, 5.6547e-02, 4.0775e-02, 2.1832e-02),
      T(1.8097e-01, 4.3488e-01, 8.0906e-01, 9.5279e-01, 9.9178e-01, 9.9642e-01,
        9.9856e-01, 9.9889e-01, 9.9934e-01, 9.9930e-01, 9.9902e-01, 9.9895e-01,
        9.9885e-01, 9.9869e-01, 9.9817e-01, 9.9681e-01, 9.9531e-01, 9.9068e-01,
        9.9072e-01, 9.8457e-01, 9.5545e-01, 8.5326e-01, 5.7086e-01, 3.4321e-01,
        1.7797e-01, 1.1025e-01, 7.5957e-02, 4.4180e-02),
      T(1.7015e-01, 4.0648e-01, 7.6375e-01, 9.3904e-01, 9.9015e-01, 9.9615e-01,
        9.9833e-01, 9.9879e-01, 9.9921e-01, 9.9915e-01, 9.9876e-01, 9.9872e-01,
        9.9846e-01, 9.9829e-01, 9.9665e-01, 9.9374e-01, 9.8525e-01, 9.7681e-01,
        9.8209e-01, 9.7998e-01, 9.6424e-01, 9.2269e-01, 7.9389e-01, 6.1845e-01,
        3.8921e-01, 2.5130e-01, 1.7380e-01, 9.7910e-02),
      T(1.4442e-01, 3.6091e-01, 7.6619e-01, 9.4772e-01, 9.9076e-01, 9.9623e-01,
        9.9853e-01, 9.9882e-01, 9.9931e-01, 9.9924e-01, 9.9895e-01, 9.9884e-01,
        9.9854e-01, 9.9812e-01, 9.9617e-01, 9.8976e-01, 9.7394e-01, 9.5045e-01,
        9.7235e-01, 9.7631e-01, 9.6480e-01, 9.5421e-01, 8.9240e-01, 8.1617e-01,
        6.3785e-01, 4.9790e-01, 4.2863e-01, 2.3719e-01),
      T(1.5188e-01, 3.8625e-01, 7.8543e-01, 9.4934e-01, 9.9114e-01, 9.9616e-01,
        9.9834e-01, 9.9878e-01, 9.9916e-01, 9.9913e-01, 9.9873e-01, 9.9861e-01,
        9.9805e-01, 9.9754e-01, 9.9534e-01, 9.8644e-01, 9.6005e-01, 9.2391e-01,
        9.4608e-01, 9.6079e-01, 9.5493e-01, 9.5188e-01, 9.2766e-01, 8.9211e-01,
        8.0528e-01, 7.2582e-01, 6.6401e-01, 4.6471e-01),
      T(1.5518e-01, 4.1780e-01, 8.4351e-01, 9.6595e-01, 9.9181e-01, 9.9595e-01,
        9.9834e-01, 9.9861e-01, 9.9898e-01, 9.9890e-01, 9.9844e-01, 9.9808e-01,
        9.9727e-01, 9.9611e-01, 9.9267e-01, 9.8220e-01, 9.6024e-01, 9.1465e-01,
        8.8761e-01, 8.7385e-01, 9.0305e-01, 9.0890e-01, 9.0726e-01, 8.6719e-01,
        8.0290e-01, 7.2254e-01, 6.5225e-01, 4.8456e-01),
      T(1.7700e-01, 4.8719e-01, 8.8348e-01, 9.6884e-01, 9.9176e-01, 9.9540e-01,
        9.9782e-01, 9.9816e-01, 9.9841e-01, 9.9822e-01, 9.9751e-01, 9.9700e-01,
        9.9570e-01, 9.9440e-01, 9.9135e-01, 9.8140e-01, 9.6939e-01, 9.2907e-01,
        8.6017e-01, 7.9329e-01, 7.6943e-01, 7.7082e-01, 7.9685e-01, 7.3216e-01,
        6.2691e-01, 5.3519e-01, 4.8933e-01, 3.5212e-01),
      T(2.1136e-01, 5.5828e-01, 9.2765e-01, 9.7843e-01, 9.9036e-01, 9.9435e-01,
        9.9651e-01, 9.9712e-01, 9.9697e-01, 9.9682e-01, 9.9507e-01, 9.9468e-01,
        9.9311e-01, 9.9215e-01, 9.8835e-01, 9.8476e-01, 9.6908e-01, 9.5477e-01,
        8.9311e-01, 8.1060e-01, 7.0127e-01, 6.3071e-01, 6.9608e-01, 6.3639e-01,
        5.5570e-01, 4.6190e-01, 4.1898e-01, 2.9993e-01),
      T(3.2360e-01, 7.0305e-01, 9.4440e-01, 9.7558e-01, 9.8877e-01, 9.9246e-01,
        9.9513e-01, 9.9546e-01, 9.9506e-01, 9.9401e-01, 9.9184e-01, 9.9088e-01,
        9.8992e-01, 9.8919e-01, 9.8544e-01, 9.8226e-01, 9.6682e-01, 9.5486e-01,
        9.1470e-01, 8.2646e-01, 6.9278e-01, 5.5555e-01, 5.1462e-01, 4.4804e-01,
        3.8711e-01, 3.1771e-01, 2.9688e-01, 2.1935e-01),
      T(5.3141e-01, 8.2496e-01, 9.3611e-01, 9.6395e-01, 9.7501e-01, 9.8039e-01,
        9.8184e-01, 9.8229e-01, 9.7864e-01, 9.7243e-01, 9.6421e-01, 9.6312e-01,
        9.6111e-01, 9.6264e-01, 9.6137e-01, 9.5721e-01, 9.4593e-01, 9.3147e-01,
        8.7769e-01, 7.7395e-01, 5.9635e-01, 4.0803e-01, 3.0769e-01, 2.7948e-01,
        1.9219e-01, 1.7522e-01, 1.4135e-01, 1.1969e-01),
      T(5.7194e-01, 7.6795e-01, 8.4733e-01, 8.7384e-01, 8.7540e-01, 8.8041e-01,
        8.7553e-01, 8.6469e-01, 8.2037e-01, 7.8384e-01, 7.3051e-01, 7.4341e-01,
        7.2965e-01, 7.5573e-01, 7.6070e-01, 7.6097e-01, 7.6178e-01, 7.4295e-01,
        6.5525e-01, 5.2254e-01, 3.7112e-01, 2.2125e-01, 1.5398e-01, 1.2773e-01,
        1.0090e-01, 9.3117e-02, 8.6961e-02, 7.8307e-02))))


    val bbox = Tensor[Float](T(215.8138, 206.8337, 252.0270, 249.3495))
    val binaryMask = Tensor[Float](480, 640)
    Utils.decodeMaskInImage(mask, bbox, binaryMask = binaryMask)

    val str = "f_U33`>NhA6Q>`0M3O1O1O100" +
      "O100HWOXBj0g=8N2O100000000001O1O2N1POYBe0R>O1O2N3L3M3M2O2M2O0O2N101Nbde5"
    val expectedRLE = MaskUtils.string2RLE(str, 480, 640)

    val outRLE = MaskUtils.binaryToRLE(binaryMask)
    outRLE.counts should be(expectedRLE.counts)
  }
}
